Menu

Search toolsChangelog

to move to openDescribe the problem, not the tool

Keep Only Selected Columns From a CSV

List one heading per line in the order you want to keep it, or use positions such as #1 and #3 when headings repeat or the file has none. The file is parsed with CSV quoting rules, every row is projected onto those positions, and a separate CSV is downloaded without the original leaving the browser.

A UTF-8 CSV, TSV or delimited text file up to 20 MB. It stays in this tab.

One exact heading per line, or positions such as #1 and #3. Leave blank to keep every column. Reorder the lines to reorder the output.

Turn this off for headerless data, then select columns only by # position.

Rows written
Data rows only; the header is not counted.
Columns kept
Columns in source
Output separator
What to take away
  1. A blank selection keeps every column; adding headings turns it into an explicit keep-list.

  2. Quoted commas and quoted line breaks stay inside their cells rather than becoming new columns or rows.

  3. A duplicated or blank heading can be selected unambiguously by its one-based position, such as #4.

How it works

How it is done

  1. Decode the chosen file as UTF-8, recording and removing any leading byte-order mark while the rows are parsed.
  2. Use the selected input separator, or count commas, semicolons, tabs and pipes outside quotes in the first complete record to detect it.
  3. Parse fields with RFC-style quoting, so doubled quotes become one quote and separators or line breaks inside a quoted field remain cell text.
  4. Resolve each non-empty keep-list line against an exact trimmed heading or a one-based # position; a blank list selects every source position.
  5. Project the header and every data row onto the same ordered positions, padding a short row with empty cells rather than shifting later data.
  6. Escape the selected values for the requested separator, write CRLF record endings, restore the source byte-order mark when one existed and offer the new file locally.

What it assumes

  • Input text is decoded as UTF-8. Legacy Windows code pages need to be converted to UTF-8 first.
  • The first row is treated as headings by default. Headerless files can be selected only with positions such as #1 and #3.
  • Heading lookup trims outer whitespace but otherwise matches exactly and case-sensitively. Duplicate headings must be selected by position.
  • The tool keeps and reorders complete columns; it does not rename headings, filter rows, infer data types or evaluate spreadsheet formulas.
  • The 20 MB input, 500,000-row, 5,000-column and 64 MB output limits keep the complete in-browser operation bounded.
  • Equivalent delimited files may use different quoting and record endings. Selected decoded cell values are preserved, not the original bytes.

Common questions

Can I select a column whose heading appears twice?

Yes. Select it by one-based position, such as #2. A repeated name is refused because silently choosing the first occurrence could keep the wrong data.

Does removing a column change the remaining cell values?

No. Cell text is parsed and written back under the selected separator. Quoting and row endings may be normalised, but the remaining decoded values are not reformatted or type-guessed.

Sources

The full method, worked example and every assumption behind this figure are on CSV Column Selector.