I have a table that looks like this:
PotA PotB PotC PotD PotE A + + + + + B - ? + + ? C + + + + + D + - + - + E + + + + +
From here I have to find all possible combinations of "+", "-" and "?". for all combinations (PotA and PotB), (PotA and PotC), etc. (PotA, PotB and PotC) and, finally, to (PotA, PotB, PotC, PotD and PotE). In fact, the line "Pot" continues to continue, but here I will only show PotE for simplicity.
To do this, first read the file as described below, and then create all the possible possibilities for a combination of the two to count each possibility.
def readDatafile(): filename = ("data.txt") infile = open(filename,'r') for line in infile.readlines(): line = line.strip() print (line)
So, the end result will be like this:
Combination: Possibility Count PotA, PotB: ++ 3 PotA, PotB: +- 1 PotA, PotB: +? 0 PotA, PotB: -+ 0 PotA, PotB: -- 0 PotA, PotB: -? 1 PotA, PotB: ?+ 0 PotA, PotB: ?- 0 PotA, PotB: ?? 0 PotA, PotC: ... PotA, PotC: ... ....... PotA, PotB, PotC, PotD, PotE: +++++ 3 PotA, PotB, PotC, PotD, PotE: ++++- 0 PotA, PotB, PotC, PotD, PotE: ++++? 0 .......
Is there a good python method for the correct logic for this problem? Should I read heading data in the form of keys and columns as a list value?
I can not get the correct logic. Please help me.