Skip to main content
Update the CSV to make clear I need a proper CSV reader
Source Link
halloleo
  • 659
  • 1
  • 13
  • 25

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"banana,apple",3,17
veggie,cauliflower,7,18
fruitanimal,apple"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?

I am looking for a command-line tool to calculate the sum of the values in a specified column of a CSV file.

Given the following sample CSV file:

description A,description B,data 1, data 2
fruit,banana,3,17
veggie,cauliflower,7,18
fruit,apple,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?

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?

Source Link
halloleo
  • 659
  • 1
  • 13
  • 25

command-line tool to sum the values in a column of a CSV file

I am looking for a command-line tool to calculate the sum of the values in a specified column of a CSV file.

Given the following sample CSV file:

description A,description B,data 1, data 2
fruit,banana,3,17
veggie,cauliflower,7,18
fruit,apple,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?