Hi Experts,
I have file with 7 fields (csv). I need a batch with calculates the sum of all the numbers in 5th column.
Field1,Field2,Field3,Field4,100,Field6,Field7
Field1,Field2,Field3,Field4,200,Field6,Field7
Field1,Field2,Field3,Field4,300,Field6,Field7
Field1,Field2,Field3,Field4,400,Field6,Field7
Batch should add all the numbers in Column 5 and write a log file saying “Total Sum is equal to : 1000”
Thanks,
Phani Akella
your data has floats/decimals. Batch is a no go for that. Use native tools like vbscript, or see response number 1.
download gawk(see my sig), then use this one liner
c:\> gawk -F”,” “{s+=$5}END{print “Total: “s}” file