I am using bash to create a script to find, group and sum fields in a CSV file. Each row will have comma-separated fields with each field following a similar convention. For each comma-separated field, there is a numeric value, then an equal sign (=), then an alphanumeric value. The "(number)=" may or may not be present in a row and, if present, the field position may vary, but appear only once in the row. In addition, the value after the equal sign will vary in length.
An example of my objective will be best. CSV File:
35=D,11=ABCD1,1=ABC,55=XYZ,38=100,40=P,18=M,54=1,59=0,10=111 35=D,11=ABCD2,1=ABC,55=XYZ,40=P,18=M,38=200,54=1,44=10.00,59=0,10=133 35=D,11=ABCD3,1=ABC,55=XYZ,40=P,18=M B,54=1,38=300,44=10.00,59=0,110=200,10=113 35=D,11=ABCD4,1=ABC,55=XYZ,38=400,40=P,18=M B F,54=1,44=10.00,59=0,110=300,10=144 35=D,11=ABCD5,1=ABC,55=ZYX,38=300,40=2,54=1,44=10.00,59=3,10=132 35=D,11=ABCD6,1=ABC,55=ZYX,38=100,40=1,18=C,54=2,59=3,10=131
I would like to have a script that would identify each field that begins with "38=" and then sum each numeric value that follows the "=" and group by each "55=". There will be a "38=" and a "55=" in each row.
The output using the above file would be (sort is optional):
55=XYZ 38=1000 55=ZYX 38=400