Select All Columns Except One
How to keep every column but one in CSV or TSV data, what the operation changes, where simple tools break on quoted fields, and how to check the output.
Selecting all columns except one is a common cleanup step for delimited text: you have a CSV or tab-separated file and want everything except one field, such as an internal ID, a notes column or a sensitive value. The operation sounds trivial, but whether the result is still correct and usable depends on how the tool splits fields, whether it selects by name or by position, and whether it rewrites values while saving. This review covers when the transformation is a good fit, what it changes, and how to confirm the output survives copying and sharing.
Is excluding one column the right approach?
For most cases where a table has many fields and only one should go, excluding that column is the better choice. It is shorter to express than listing every column you want to keep, and it keeps working if new columns are added later. The main tradeoff is that the operation is lossy. Once the column is gone, nothing in the output records that it existed. If the removed field is a key that another file or process uses to match rows, removing it can break that link.
Recommendation: exclude by column name with a parser that understands your file's quoting rules, and keep the original file unchanged. Positional exclusion, meaning "drop the third field", is acceptable only for simple, stable data with no quoted delimiters. Where the recipient needs to read the result rather than load it into software, plain text is often not the best format (see the section on sharing below).
What the operation changes
The intended change is narrow. One field is removed from the header and from every data row, along with one delimiter per line. All other values should stay byte-for-byte the same and in the same order. In practice, two different mechanisms produce this result, and they behave differently on real data.
- Positional splitting: the tool splits each line on every occurrence of the delimiter and drops field N. It is fast and simple, but it does not know about quotes, so a comma inside a quoted value is treated as a field boundary.
- Parsed exclusion: the tool reads the file as structured CSV or TSV, recognizes quoted fields and escaped quotes, removes the named column, and writes the rows back out. This handles embedded delimiters correctly, but because the file is rewritten, quoting style, line endings or value formatting may change.
The word "select" can also mean different things. In some spreadsheet and editor contexts it means highlighting cells on screen, which changes nothing in the stored data until you copy or delete. In command-line and database tools it means producing new output without the column. This article is about the second meaning: a stored change to the text.
A worked example
The following input has a quoted name containing a comma and a quoted note containing escaped double quotes. The goal is to remove the notes column.
id,name,notes,city
1,"Lee, Ana",prefers mornings,Austin
2,Sam Ortiz,"said ""call later""",Denver
A quote-aware tool excluding the notes column should produce:
id,name,city
1,"Lee, Ana",Austin
2,Sam Ortiz,Denver
A naive split on commas that drops field 3 gives a different result. The header and row 2 can look correct by coincidence, but row 1 is split into five pieces (1, "Lee, then Ana", then prefers mornings, then Austin), so removing the third piece produces corrupted output:
id,name,city
1,"Lee,prefers mornings,Austin
Row 2 is wrong as well. Its note contains no commas, so splitting works, but the whole point was to drop that note, and positional splitting only gets this right because nothing else on the line contains a comma. Errors like this are easy to miss if you only check the header and the first few lines.
Common ways to do it
These examples show documented options in widely used tools. They have not been tested against your data, and the caveats below matter more than the syntax.
# GNU coreutils cut: positional, not quote-aware
cut -d',' -f3 --complement data.csv
# csvkit: quote-aware, exclude by name
csvcut -C notes data.csv
# pandas: quote-aware, exclude by name
import pandas as pd
pd.read_csv("data.csv", dtype=str, keep_default_na=False) \
.drop(columns=["notes"]) \
.to_csv("out.csv", index=False)
-- DuckDB SQL
SELECT * EXCLUDE (notes) FROM 'data.csv';
-- BigQuery SQL
SELECT * EXCEPT (notes) FROM my_table;
| Approach | Quote-aware | Selects by | Main caveat |
| GNU cut --complement | No | Position | The --complement flag is a GNU extension and is not available in BSD or macOS cut. It also breaks on quoted delimiters. |
| csvkit csvcut -C | Yes | Name or position | Rewrites the file, so quoting style in the output may differ from the input. |
| pandas drop(columns=...) | Yes | Name | Type inference can alter values unless every column is read as text. |
| SQL EXCLUDE / EXCEPT | Depends on the engine's CSV reader | Name | Not part of standard SQL. Syntax and support vary by database. |
The pandas example reads every column as text on purpose. With default settings, a value like 02134 can be read as the number 2134, and empty cells can become missing values that are written back differently. Neither of these is caused by removing a column, but both show up in the output and change its meaning. Any tool that parses and re-serializes data can have similar side effects, so compare a sample of rows before and after.
Will the result stay usable after copying or sharing?
Unlike Unicode styling or reversed text, removing a column leaves the characters in every remaining field unchanged when the tool works correctly. Accented letters, combining marks and emoji should pass through untouched. Search, editing and screen readers handle the output the same way they handled the original. The usability risks come from structure, not from characters.
- Field count: each row should have exactly one field fewer than before. A quick per-row field count with a quote-aware tool will catch the kind of corruption shown in the example.
- Delimiter on paste: many spreadsheet applications split tab-separated text into columns when it is pasted, but comma-separated text pasted as plain text may land in a single column. Behavior depends on the application and its settings, so test the specific destination instead of assuming.
- Encoding and line endings: tools that rewrite files may add or drop a byte-order mark or change line endings. Some destinations are sensitive to these details.
- Downstream expectations: anything that reads the file by column position, rather than by header name, will see shifted columns after removal.
If people will read the result rather than import it, delimited text is a weak format. A screen reader will read a raw CSV line as a run of values and punctuation, with no indication of which header each value belongs to. For human readers, convert the cleaned data into a proper table, either a spreadsheet with a header row or an HTML or document table with marked-up headers, so the structure is visible and accessible. Keep the delimited file for machines and the table for people.
Gaps in this review
No specific tool was tested for this article, and no measurements of speed, file-size limits or accuracy are available. The behaviors described come from documented tool options and general CSV parsing rules, not from scoped tests. For browser-based or hosted column tools, nothing here describes how they handle quoting or what they do with uploaded data. Check their documentation, and run the example above or your own edge cases through them before relying on them for sensitive or important files.