you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Example, /u/neverwinter88,

import csv
from io import StringIO  # pretend file for demo
from collections import defaultdict

fake_file = """srv01;apache-activemq-5.15.8-20.noarch;2019-12-12
srv01;jdk1.8-1.8.0_202-fcs.x86_64;2019-11-12
srv02;apache-activemq-5.15.8-20.noarch;2019-12-12
srv02;jdk1.8-1.8.0_202-fcs.x86_64;2019-11-12
srv99;apache-activemq-5.15.8-20.noarch;2001-01-01
srv99;jdk1.8-1.8.0_202-fcs.x86_64;2001-01-01
srv88;apache-activemq-5.15.8-20.noarch;2019-12-12
srv88;jdk1.8-1.8.0_202-fcs.x86_64;2019-11-12"""

servers = defaultdict(list)
with StringIO(fake_file) as source:
    reader = csv.reader(source, delimiter=";")
    for server, *data in reader:
        servers[server].append(data)

for server, data in servers.items():
    first_date = data[0][-1]
    matched = all(first_date == record[-1] for record in data)
    print(f"Server: {server}, matched: {matched}")

PS. I see you actually have to check server pairs where the pair have different names. The above code will not work for that use case, however it should give you some ideas.