Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
design
#1
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
Reply
#2
What do you mean by "compare"? What do you want for output?
Reply
#3
Big Grin 
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
==========

Machine1 Machine2 Machine3
P1 dog cat dog
P2 3 3 3
P3 1 2 4
Reply
#4
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.
Reply
#5
(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.

It looks like all you really want is a table with the machine as columns and the parameter as rows.

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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020