Nov-08-2023, 07:08 PM
(This post was last modified: Nov-09-2023, 12:33 AM by rob101.
Edit Reason: code mod
)
This is maybe a little rough, and I don't fully grasp some of the details in your post, but it could be a starting point for you:
import csv PING_RUN = {} TICKETS = {} # KEYS IP_ADDRESS = 0 STORE = 1 REGISTER = 2 STATUS = 3 with open("ping.csv", mode="r", encoding="UTF-8") as ping: READER = csv.reader(ping) for row in READER: PING_RUN[row[STORE]] = [row[IP_ADDRESS], row[REGISTER], row[STATUS]] # KEYS STORE = 0 PROBLEM = 1 TICKET = 2 DATE = 3 with open("ser.rpt", mode="r", encoding="UTF-8") as ser_rpt: READER = csv.reader(ser_rpt) for row in READER: TICKETS[row[TICKET]] = {row[STORE]: [row[PROBLEM], row[DATE]]} for ticket in TICKETS: details = TICKETS[ticket] # store = list(details.keys())[STORE] store = [*details][STORE] # this is a nice way if store in PING_RUN: print(f"Ticket: {ticket}") print(f"Store {store}") print(f"{details[store]}") print()
Output:Ticket: 29743
Store 6
['Register 202 down', '11/7/2023']
Ticket: 29745
Store 6
['Register 203 down', '11/7/2023']
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein