CSV to Any Delimiter
A delimiter converter rewrites a file with the separator your consumer expects: a pipe, a semicolon, a caret, an ASCII unit separator, or something of your own. The part that matters is the quoting, which is applied against the delimiter you picked rather than against a comma, so a value containing your separator still lands in one field. Nothing is uploaded.
Need to clean or reorder columns first? Open the app
The bug in every hand-rolled version
Changing a delimiter looks like the simplest transformation there is. Split each row, join it with the new separator, done. Two lines of code, and it is wrong in a way that does not show up until the file is somewhere else.
A field needs quoting when it contains the character that separates fields. Swap to a pipe and a value like low | reorder now contains the delimiter, so that row has one more field than every other row. The reader either errors on a ragged row or, worse, shifts every column after it and carries on.
The half-fix is to run the rows through a CSV writer with the new delimiter set. That still quotes against a comma, so a value containing a comma gets pointless quotes and a value containing a pipe gets none. Same bug, more machinery.
Here the writer quotes against whatever delimiter you chose:
ticket|status|note
1042|open|"blocked | waiting"
1043|closed|shipped, delivered
The note containing a pipe is quoted. The note containing a comma is not, because a comma means nothing in a pipe-delimited file. That is the correct output and it is what you would want a person to write by hand.
Which separator, and why
Semicolon. Spreadsheets in most European locales use it as the field delimiter, because the comma is the decimal separator there. If you have sent a CSV to a colleague in Germany or France and been told it opened in one column, a semicolon is the fix.
Pipe. Common in data warehouse loads and older feeds. Its real advantage is that a pipe appears in free text far less often than a comma does, so most files come out with no quoting at all and stay readable in a terminal.
Caret and colon. Both turn up in finance and telecoms formats, usually because somebody decided a pipe was not rare enough.
ASCII record and unit separators. The characters at 0x1E and 0x1F exist in ASCII for exactly this purpose, and because they never appear in ordinary text a file using them needs no quoting or escaping at all. The trade is that they are invisible in an editor, so the file is unreadable by eye. For a machine-to-machine feed carrying free text with commas, quotes and newlines in it, they are a genuinely good and underused choice.
Custom. Anything you type, including a multi-character string such as ::. That is fine for a file you will parse yourself, and you get a warning, because most spreadsheet importers take a single character for their delimiter setting and cannot open it.
The Excel sep= line
Excel has an undocumented but long-standing behaviour: if the first line of a file is exactly sep= followed by one character, it treats that as a directive naming the delimiter and opens the file accordingly, skipping the line.
sep=;
ticket;status;note
1042;open;waiting
That is the only way to make a semicolon or pipe file open correctly in Excel by double-clicking, without walking somebody through the import wizard. If you are sending a file to a colleague who will open it in Excel and nowhere else, it saves a conversation.
Everything else treats that line as data. pandas gives you a one-column first row, a database load rejects it, and a script reading the header gets sep=; as a column name. So it is off by default and comes with a warning when you turn it on.
Windows line endings are the other compatibility switch, for a legacy consumer that expects carriage return plus line feed and mis-parses a bare newline.
The input side is symmetric: the source delimiter is detected from the text, so this rewrites a semicolon file as pipes or a tab file as semicolons just as happily as it handles a comma file. Pin it explicitly when the detection is wrong, which happens on files where commas appear more often inside quoted values than between them.
The download extension follows your choice: a tab gives you .tsv, a comma gives .csv, and anything else gives .txt, since there is no registered extension for a caret-delimited file.
Questions
Why does the quoting depend on the delimiter?
Because a field only needs quoting when it contains the character that separates fields. Joining rows with a pipe and no further thought produces a broken file the moment a value contains a pipe, and quoting against a comma instead is the same bug with an extra step. Here the writer quotes against whichever delimiter you chose, so a pipe-delimited file with a pipe inside a value comes back with the right number of columns.
What is the sep= line for?
Excel reads a first line of exactly sep= followed by one character as a directive naming the delimiter, and opens the file accordingly. It is the only way to make a semicolon or pipe file open correctly in Excel without going through the import wizard. Every other reader treats that line as data, so leave it off unless the file is going to Excel and nowhere else.
Can I use a multi-character delimiter?
Yes, through the custom option, and you get a warning. Something like a double colon is fine for a file you will parse yourself with a known separator, and most spreadsheet importers cannot open it because their delimiter setting takes a single character. Worth knowing before you send it to somebody.
What are the ASCII separator characters?
Two control characters, 0x1E and 0x1F, that exist in ASCII specifically to separate records and fields. Because they never appear in ordinary text, a file using them needs no quoting or escaping at all. They are invisible in an editor, which is the trade, and they are a genuinely good choice for a machine-to-machine feed carrying free text.
Why would I want a pipe or a semicolon?
A semicolon is what spreadsheets in most European locales expect, because the comma is the decimal separator there. A pipe is common in data warehouse loads and legacy feeds, and it is rarer inside free text than a comma, so files stay unquoted and readable. A caret shows up in older finance and telecoms formats.
Does the source have to be comma separated?
No. The input delimiter is detected from the text, so this rewrites a semicolon file as pipes or a tab file as semicolons just as happily. You can pin the input delimiter when the detection gets it wrong, which happens on files where a comma appears more often inside quoted values than between them.
Is anything uploaded?
No. Everything runs in your browser tab, with nothing sent to a server, nothing kept between visits and no row cap. The file extension follows your delimiter: tab gives .tsv, comma gives .csv, anything else gives .txt.
Related
Convert your CSV to another delimiter
No sign-up, no upload, no row cap. Any separator, quoted against the one you actually chose.
Back to the converter