I have data containing [code] [status] [device type] in a list of arrays. Device type can either be A or B. The array looks like this:
sample_list = [["C1-0001", "Offline", "A"], ["C1-0001", "Offline", "B"], ["C1-0002", "Online", "A"]]
The list of arrays could be interpreted like this:
I have another list containing [code] only.
The list of codes could be interpreted like this:
Basically, I want to check the statuses of the list containing [code] only including some other parameters that could be derived from the list of arrays.
All in all, the parameters I want to output are its [solution] [code] [status] [Online A type device] [Offline A type Device] [Online B type device] [Offline B type device].
solution is C if it has only 1 type "A" device. B if otherwise.status is "Online" if even just 1 type of device is on for a particular "code"
This kinda sums up the outputs I want:
I was doing stuff differently before using dictionaries and got my solution here: How can I tally my data such that the correspondence of my data simplifies like an OR operation?
But now that I have extra parameters and basically having duplicate [code] on my output which is not allowed in dictionaries, I'm having trouble wrapping my head around the data. Hope you guys could me some ideas.
EDIT: I successfully outputted the [solution] [code] and [status] in order. For the online devices on each type, I was thinking if there's something that checks if index 0 hasn't change for an array inside a list if I'm cycling through many lists inside a list as such:
sample_list = [["C1-0001", "Offline", "A"], ["C1-0001", "Offline", "B"], ["C1-0002", "Online", "A"]]
Here is my current code on the device statuses:
for i in sites: for j in nested_list if j[0] == i and j[1] == "Online" and j[2] == "A": something elif j[0] == i and j[1] == "Offline" and j[2] == "A": something elif j[0] == i and j[1] == "Online" and j[2] == "B": something elif j[0] == i and j[1] == "Offline" and j[2] == "B": something
The sites list are the codes duplicated such that if it contains 2 devices, it will appear twice disregarding the device type.
The nested_list list contains the arrays of [codes] [status] [device type]