Why people convert CSV to TSV
- To paste into a spreadsheet. Excel and Google Sheets split pasted text into cells at tabs, so tab separated text pastes as a grid, and comma separated text does not.
- To avoid quoting. If your text holds many commas, as addresses and sentences do, almost every CSV value needs quotes. In TSV the same values are plain.
- To load a database or feed a tool that expects tabs. PostgreSQL's COPY text format and MySQL's LOAD DATA both default to a tab between fields. Both also expect backslash codes for tabs, line breaks and empty values, and this converter does not write those, so check any value that holds such characters.
What happens to quotes, commas and line breaks
The CSV is read first, with its quotes understood: a quoted value may hold the delimiter and line breaks, and two quote marks in a row stand for one. The values are then written again for TSV. For example, the CSV row Ana,"Lisbon, Portugal",31 becomes three values, Ana, Lisbon, Portugal and 31, with a tab between them, and no quotes, because the comma is no longer special.
A value that holds a tab or a line break still needs protection, and the converter wraps it in double quotes, with inner quote marks doubled. Spreadsheets understand this when you paste or open the result. Many command line tools and database loaders do not, because simple TSV has no quoting. Remove or replace tabs and line breaks in such data before you convert.
A value with a space at its start or end is also wrapped in quotes, so the space is not lost when the file is read again.
Reading the CSV you start with
The delimiter is detected by trying a comma, tab, semicolon and pipe on the first rows, ignoring delimiters inside quotes. That covers the common cases, including the semicolon CSV that Excel writes in many European countries. A file with only one column, or a column whose text holds many commas, can fool the guess, so choose the Delimiter in the input by hand in those cases.
Rows with fewer values than the header are filled with empty cells, extra values go into extra columns called column5, column6 and so on, and a repeated header becomes name and name_2. Rows with no content are skipped. A note under the result lists each repair.
Pasting the result into Excel
Excel applies its own rules to pasted text. A value such as 00123 can lose its zeros and a long number can turn into scientific notation. To keep them, format the target columns as Text before you paste. Better, convert to a real workbook with the CSV to Excel page, which writes those values as text cells.