in reply to Accumulate values for each data field

Something like this ?

(The code is as clear as your specifications)

>perl -anF, -e "$x{$F[3]}+=$F[1] if $F[1]=~/^\d+/}{print qq|$x{$_}\t$_ +\n| for sort keys %x" data1.txt 2 "456.123.00" 2 "456.147.00" 6 "456.321.07" 5 "456.321.08" 5 "456.321.09" 12 "456.321.11" 6 "456.321.12" 1 "456.321.15" 1 "456.321.29" 1 "456.321.30" 1 "456.321.31" 1 "456.321.32" 1 "456.325.10" 2 "456.325.11" 2 "456.325.15" 2 "456.325.30" 2 "456.325.31" 8 "460.339.01" 16 "460.339.02" 2 "460.339.03" 4 "460.339.04"

        "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin

Replies are listed 'Best First'.
Re^2: Accumulate values for each data field
by JobC (Acolyte) on Feb 10, 2016 at 00:37 UTC

    Very Nice! Actually, I need to output the entire data line, but that would be a start. I will try to make a better example. There are 400 lines of code that need to be paired down, and I thought I could shortcut the process. Sorry!

      Is this output what you need?
      1,6,ea,456.321.07,"TRAY, BOTTOM, 66#47L-20503",2/9/2016 2,6,ea,456.321.12,"TRAY, TOP, 66#51R-20507",2/9/2016 3,1,ea,456.321.15,"TUBE, TALL, 66#15CR-21862",2/9/2016 4,8,ea,460.339.01,"WRAP, LGE GRP, xx#03CR-28081",2/9/2016 5,16,ea,460.339.02,"TRAY LGE GRP, xx#49R-27709",2/9/2016 8,2,ea,460.339.03,"WRAP, SM GRP, xx#02CR-28079",2/9/2016 9,4,ea,460.339.04,"TRAY, SM GRP, xx#50R-27711",2/9/2016 14,2,ea,456.325.30,"CNT LONG BOX BTM#08CR-23399",2/9/2016 15,2,ea,456.325.31,"CNT LONG BOX TOP#27L-23400",2/9/2016 16,2,ea,456.123.00," KIT ASSY BOX#F29487",2/9/2016 17,2,ea,456.147.00," KIT ASSY BOX 2, SC#F29494",2/9/2016 18,2,ea,456.325.11,"BOX, 34/43"", WMT UPR#11CR-20517",2/9/2016 19,2,ea,456.325.15,"BOX, 34""/42"" WMT UPR, BTM#13CR-21227",2/9/2016 21,5,ea,456.321.08,"TUBE, MEDIUM/SHORT, 66#14CR-20539",2/9/2016 22,5,ea,456.321.09,"TOP SPRT, 66#12CR-20504",2/9/2016 24,12,ea,456.321.11,"BRACE, MEDIUM END#22L-20505",2/9/2016 35,1,ea,456.325.10,"BOX, 22/29"", WMT UPR#18CR-20518",2/9/2016 37,1,ea,456.321.29,"TRAY, BTM, 94#45L-20549",2/9/2016 38,1,ea,456.321.30,"TUBE,MED/SHORT, 94#05CR-20550",2/9/2016 39,1,ea,456.321.31,"SPRT, TOP, 94#04CR-20501",2/9/2016 40,1,ea,456.321.32,"TRAY, TOP, 94#43R-20548",2/9/2016
      This cuts off the last 2 columns. Also for all the other columns, only the cols from the first occurrence are used.

      You said this data was going to be used in another program or processed further in a larger program. Maybe it would be helpful to describe what is needed to be done.