I am working on a program that will compare two .csv files. After extracting the relevant data from one of the csv files into an array of arrays, I need to combine related entries. For example, I would want to turn this array:
[["11/13/15", ["4001", "1392"], "INBOUND"],
["11/13/15", ["4090", "540"], "INBOUND"],
["11/13/15", ["1139", "162"], "INBOUND"],
["11/13/15", ["1158", "64"], "INBOUND"],
["11/13/15", ["4055", "352"], "OUTBOUND"],
["11/13/15", ["4055", "448"], "OUTBOUND"],
["11/13/15", ["4055", "352"], "OUTBOUND"],
["11/13/15", ["1139", "162"], "OUTBOUND"],
["11/13/15", ["1158", "64"], "OUTBOUND"],
["11/13/15", ["4091", "520"], "OUTBOUND"]]
into this:
[["11/13/15", ["4001", "1392"], "INBOUND"],
["11/13/15", ["4090", "540"], "INBOUND"],
["11/13/15", ["1139", "162"], "INBOUND"],
["11/13/15", ["1158", "64"], "INBOUND"],
["11/13/15", ["4055", "1152"], "OUTBOUND"],
["11/13/15", ["1139", "162"], "OUTBOUND"],
["11/13/15", ["1158", "64"], "OUTBOUND"],
["11/13/15", ["4091", "520"], "OUTBOUND"]]
For some element of the array, if its items at [0], [1][0], and [2] match those of another one, then create a new item (array) with its item at [1][1] being the sum of all the items at [1][1] and delete the old arrays. If it would be easier, I can change the way the relevant data is extracted so that the item at [1] is not an array and each row has 4 items instead of 3.
[4][1][1]of the resulting array, which is the sole crucial value. It should be 1152, not 1115. I must say your question is sloppy.