csvkit.org
CSV (Comma-Separated Values) utilities, in the browser
Say hi →

CSV Column Math

updated 7 September 2026

Add the column the spreadsheet would have given you: a line total, a margin, a unit price, a share of the total. Write the formula with column names in braces — {price} * {qty} — and every row is computed at once, including the rows where a cell is empty or a divisor is zero, which are reported rather than silently turned into NaN.

formula
column
inputs
Drop a .csv file here, or
ready

CSV Column Math

Every CSV eventually needs a column that is not in it. The usual route is Excel — open, type a formula in D2, drag it down 40,000 rows, watch the leading zeros vanish and the dates turn American, then export and hope. This does the one step you wanted and touches nothing else: same rows, same order, same text in every other column, one new column at the end.

How to use it

  1. Paste or drop the CSV. The column names appear under the panes — click one to drop {that_name} into the formula at the cursor.
  2. Write the formula. {price} * {qty}, ({revenue} - {cost}) / {revenue}, round({weight} * 2.20462, 1).
  3. Name the new column and choose where it goes — last, first, or straight after an existing column. Use the name of a column that already exists and it is replaced in place.
  4. Read the status line. It says how many rows computed, and how many came out blank because a cell was empty, a cell was not a number, or a divisor was zero.

The formula language

Column names go in braces: {unit price} works with the space in it, which is why braces rather than bare words. Everything else is what you would type into a spreadsheet.

Formulas are parsed, not evaluated. There is no eval anywhere in this page: the text becomes a small tree of operations and nothing else. A formula pasted from a colleague cannot run code in your browser.

Numbers as they really appear in CSVs

Exported data is rarely a clean 1234.5. With read messy numbers on — the default — these all become numbers:

Turn it off and only a plain number counts, which is the right setting when a column that should be numeric secretly is not and you want to know rather than get an answer.

What happens to the rows that cannot be computed

A spreadsheet writes #DIV/0! or #VALUE! into the cell and moves on, and those strings then travel through your pipeline as data. Here the cell is left empty and the reason is counted in the status line: “1,204 of 1,210 rows computed into "total" · 4 left blank — an input cell was empty · 2 left blank — division by zero.” If you would rather have a number, switch the empty-cell or non-numeric handling to treat as 0 — but do it on purpose, having seen the count.

Examples

Limits

Privacy

100% client-side. The file is parsed and computed in your browser; nothing is uploaded. See the privacy policy.

Related

Add a column for constants, row numbers and templates · Clean numbers to fix the source column instead · Group by for subtotals · SQL over CSV when one formula is not enough · Filter rows to keep the ones your new column flags · Stats for the column you just built.