I am trying to perform several operations on the myList list of lists below and am having some trouble figuring it out. I am very new to Python.
myList = [
['Issue Id','1.Completeness for OTC','Break',3275,33,33725102303,296384802,20140107],
['Issue Id','2.Validity check1 for OTC','Break',3308,0,34021487105,0,20140107],
['Issue Id','3.Validity check2 for OTC','Break',3308,0,34021487105,0,20140107],
['Issue Id','4.Completeness for RST','Break',73376,1,8.24931E+11,44690130,20140107],
['Issue Id','5.Validity check1 for RST','Break',73377,0,8.24976E+11,0,20140107],
['Liquidity','1. OTC - Null','Break',7821 0,2.28291E+11,0,20140110],
['Liquidity','2. OTC - Unmapped','Break',7778,43,2.27712E+11,579021732.8,20140110],
['Liquidity','3. RST - Null','Break',335120,0,1.01425E+12,0,20140110],
['Liquidity','4. RST - Unmapped','Break',334608,512,1.01351E+12,735465433.1,20140110],
['Liquidity','5. RST - Valid','Break',335120,0,1.01425E+12,0,20140110],
['Issue Id','1.Completeness for OTC','Break',3292,33,32397924450,306203929,20140110],
['Issue Id','2.Validity check1 for OTC','Break',3325,0,32704128379,0,20140110],
['Issue Id','3.Validity check2 for OTC','Break',3325,0,32704128379,0,20140110],
['Issue Id','4.Completeness for RST','Break',73594,3,8.5352E+11,69614602,20140110],
['Issue Id','5.Validity check1 for RST','Break',73597,0,8.5359E+11,0,20140110],
['Unlinked Silver ID','DQ','Break',3201318,176,20000000,54974.33386,20140101],
['Missing GCI','DQ','Break',3201336,158,68000000,49351.9588,20140101],
['Missing Book','DQ Break',3192720,8774,3001000000,2740595.484,20140101],
['Matured Trades','DQ','Break',3201006,488,1371000000,152428.8348,20140101],
['Illiquid Trades','1.Completeness Check for range','Break',43122,47,88597695671,54399061.43,20140107],
['Illiquid Trades','2.Completeness Check for non','Break',39033,0,79133622401,0,20140107]
]
I am trying to get the result below but do not know how to do so:
newList = [
['Issue Id','1.Completeness for OTC:2.Validity check1 for OTC:3.Validity check2 for OTC','Break',3275,33,33725102303,296384802,20140107],
['Issue Id','4.Completeness for RST:5.Validity check1 for RST','Break',73376,1,8.24931E+11,44690130,20140107],
['Liquidity','1. OTC - Null','Break:2. OTC - Unmapped','Break',7821 0,2.28291E+11,0,20140110],
['Liquidity','3. RST - Null:4. RST - Unmapped:5. RST - Valid','Break',335120,0,1.01425E+12,0,20140110],
['Issue Id','1.Completeness for OTC:2.Validity check1 for OTC:3.Validity check2 for OTC','Break',3292,33,32397924450,306203929,20140110],
['Issue Id','4.Completeness for RST:5. RST - Valid','Break',73594,3,8.5352E+11,69614602,20140110],
['Unlinked Silver ID','DQ','Break',3201318,176,20000000,54974.33386,20140101],
['Missing GCI','DQ','Break',3201336,158,68000000,49351.9588,20140101],
['Missing Book','DQ Break',3192720,8774,3001000000,2740595.484,20140101],
['Matured Trades','DQ','Break',3201006,488,1371000000,152428.8348,20140101],
['Illiquid Trades','1.Completeness Check for range','Break',43122,47,88597695671,54399061.43,20140107],
['Illiquid Trades','2.Completeness Check for non','Break',39033,0,79133622401,0,20140107]
]
Rules to create newList. Create a new list in the newList list of lists if the values in the lists meet the following conditions:
multiple lists that match on `myList[i][0]` and `myList[i][7]` but with have (1) sums of `myList[i][3]` and `myList[i][4]` and (2) sums of `myList[i][5]` and `myList[i][6]` that are different from each other are just listed as is in newList
if multiple lists match on both `myList[i][0]` (this is the type) and `myList[i][7]` (this is the date) are the same then create a new list for each set of lists with mathcing `myList[i][0]` and `myList[i][7]` that have (1) sums of `myList[i][3]` and `myList[i][4]` and (2) sums of `myList[i][5]` and `myList[i][6]` that are different from the other lists with mathcing `myList[i][0]` and `myList[i][7]`. I also am trying to concatenate `myList[i][1]` separated by a ':' for all those lists with matching `myList[i][0]` and `myList[i][7]` and with sums of `myList[i][3]` + `myList[i][4]` and `myList[i][5]` + `myList[i][6]` that match. So essentially for this case only those lists in `myList` with sums of `myList[i][3]` + `myList[i][4]` and `myList[i][5]` + `myList[i][6]` are different from the other lists are then listed in newList.
The above newList illustrates these results I am trying to achieve. If anyone has any ideas how to do this they would be greatly appreciated. Thank you!