Skip to content

Instantly share code, notes, and snippets.

View thestuntcoder's full-sized avatar
🇨🇭

Dean Starkmann thestuntcoder

🇨🇭
View GitHub Profile
@nepsilon
nepsilon / csv-file-how-to-sum-up-all-numbers-in-a-given-column.md
Created February 14, 2017 21:49
In a CSV file, how to sum up all numbers in a given column? — First published in fullweb.io issue #87

In a CSV file, how to sum up all numbers in a given column?

When you only have a few thousand lines, a spreadsheet software will do. But when you got millions, it’s another job.

Unix has the awk command, which you might not use too often, if at all, but is both powerful and easy get started with. See here how to sump up all numbers in the 3rd column in records.csv:

awk -F',' '{sum+=$3} END {print sum}' records.csv