Overview
Introduction
Adding a new leading column to a CSV, an ID column, a source label, a batch tag, normally means opening a spreadsheet, inserting a column, and dragging a value down every row by hand. This tool does the same thing from pasted text in a couple of clicks.
It's built for the common case of tagging every row in an export with the same constant value in a new first column, before the data goes on to some other pipeline or import step.
What Is CSV Column Prepender?
A structural CSV tool that inserts one new column at position 0 of every row: your chosen header name in row 0, and your chosen fill value repeated in every data row below it.
It operates on the raw grid of cells rather than assuming any particular schema, so it works on any well-formed CSV regardless of column count or content.
How CSV Column Prepender Works
The input is parsed into a grid of rows and cells honoring RFC 4180 quoting, then padded so every row has the same width even if the source CSV had ragged rows.
A new cell is unshifted onto the front of every row, using the header name for row 0 and the fill value for every row after it, and the grid is re-serialized back into CSV text.
When To Use CSV Column Prepender
Use it when you need to tag every row of an export with the same constant, a source name, an import batch ID, a status flag, in a new first column.
It's also handy when downstream tooling expects a specific column (like an ID or category) to always be column 0, and your source data doesn't have one yet.
Often used alongside CSV Column Appender, CSV Column Inserter and CSV Column Deleter.
Features
Advantages
- No spreadsheet program required; paste CSV text in, get CSV text out.
- Correctly re-escapes any field that itself contains commas, quotes, or newlines.
- Handles ragged input rows by padding them to a rectangle before inserting, so no column ever ends up misaligned.
Limitations
- Every data row gets the exact same fill value; there's no per-row value support in this tool.
- Only a comma delimiter is supported; tab- or semicolon-delimited files need converting first.
Column-insertion tools compared
| Tool | Insertion point |
|---|---|
| CSV Column Prepender | Always index 0 (start) |
| CSV Column Appender | Always the last index (end) |
| CSV Column Inserter | Any index you choose |
Examples
Best Practices & Notes
Best Practices
- Pick a clear, unique header name so the new column doesn't collide with an existing one further down the row.
- If different rows need different values, prepend a placeholder column here, then fill it in with CSV Column Replacer's newline-list mode.
- Check the row count in the output matches your input, since a missing trailing newline in ragged CSVs can otherwise be easy to miss.
Developer Notes
Implemented as `[index === 0 ? headerName : fillValue, ...row]` over every padded row; the padding step (`padGridToRectangle`) runs first so a ragged source CSV never produces a jagged result after the insert.
CSV Column Prepender Use Cases
- Adding a constant source or batch-ID column before merging several CSV exports together
- Inserting a status or flag column that a downstream import script expects at position 0
- Prepending a row-type label before combining data from multiple systems
Common Mistakes
- Expecting each row to get a different value; this tool only ever repeats one fill value across all data rows.
- Forgetting that all existing columns shift right by one, which can break any code that references columns by a hardcoded index.
Tips
- Leave the fill value blank if you just want an empty placeholder column to fill in manually or with another tool later.
- Pair with CSV Column Renamer if you insert now and decide on a better header name after seeing the output.