I am looking for a command-line tool to calculate the sum of the values in a specified column of a CSV file. (Update: The CSV file might have quoted fields, so a simple solution just to break on a delimiter (',') does not work.)
Given the following sample CSV file:
description A,description B,data 1, data 2
fruit,"banana,apple",3,17
veggie,cauliflower,7,18
animal,"fish,meat",9,22
I want to build the sum, for example, over the column data 1 with the result 19.
I have tried to use csvkit for this but didn't get very far. Are there other command-lien tools specialised in this CSV operation?
groupbystuff for datamash and the reorder parts for miller (so, e.,g.,datamash --header-in -st , sum 3,mlr --csv -N stats1 -a sum -f 3)