![]() |
design - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: design (/thread-34734.html) |
design - fakka - Aug-26-2021 HI I have data that will look like this. Idea is to compare all parameters from machine 2 and 3 to the master machine (machine 1). Whats the best way to store this ...... and then to compare. Was thinking a DICT for each ? But not sure. machine1, parameter, value machine1, parameter, value machine1, parameter, value machine2, parameter, value machine2, parameter, value machine2, parameter, value machine3, parameter, value machine3, parameter, value machine3, parameter, value RE: design - deanhystad - Aug-26-2021 What do you mean by "compare"? What do you want for output? RE: design - fakka - Aug-26-2021 machine1, p1, dog machine1, p2, 3 machine1, p3, 1 machine2, p1, cat machine2, p2, 3 machine2, p3, 2 machine3, p1, dog machine3, p2, 3 machine3, p3, 4 Output really just has to spit out the differences ...... but "ideally" Quote:DifferencesReport RE: design - deanhystad - Aug-26-2021 This does not look like differences. P2 is the same for all three machines. The value of P1 is different for Machine2, but Machine1 and Machine3 are the same. It looks like all you really want is a table with the machine as columns and the parameter as rows. RE: design - fakka - Aug-26-2021 (Aug-26-2021, 03:15 PM)deanhystad Wrote: This does not look like differences. P2 is the same for all three machines. The value of P1 is different for Machine2, but Machine1 and Machine3 are the same. Yes sorry thats the formatting - the differences were highlighted in original response - but didnt show up. Any output is fine ...... the tabular approach is just preffered ... but it can even be as simple as machine1, p1, dog machine1, p2, 3 machine1, p3, 1 machine2, p1, cat machine2, p2, 3 machine2, p3, 2 machine3, p1, dog machine3, p2, 3 machine3, p3, 4 Machine2 value for p1 is cat and differs from machie1. Machine2 value for p3 is 1and differs from machine1. Machine3 value for p3 is 4 and differs from machine 1 I was just struggling with how to do this eg this code makes sense for k,v in firstdict.iteritems(): if k in seconddict and seconddict[k] != v: print("Key: {}, Value: {}".format(k, seconddict[k])) But then I need 3 separate dictionaries ........ wasnt sure if thats the right way to go. Simpler way. |