Reading TSV Files with pandas read_csv — The sep Parameter
- Use pd.read_csv("file.tsv", sep="\t") — the only difference from a CSV read is the sep parameter.
- sep and delimiter are aliases in pandas — either works.
- For .tsv.gz compressed files, add compression="gzip" to the same call.
- For a no-code conversion without Python, the browser TSV to CSV converter takes seconds.
Table of Contents
Loading a TSV file in pandas is almost identical to loading a CSV — the only difference is one parameter. Where pandas defaults to sep=',' for CSV, you need sep='\t' for tab-separated data. Everything else — headers, encoding, dtypes, chunking — works the same way.
This guide covers the correct syntax, the most common mistakes (including why the data collapses into one column), handling compressed files, and encoding issues. If you are not a pandas user and just need to convert a TSV file to CSV for a spreadsheet tool, skip to the browser alternative at the bottom.
The Correct pandas read_csv Call for a TSV File
The basic call:
import pandas as pd
df = pd.read_csv('data.tsv', sep='\t')
That is it. The sep parameter tells pandas to split columns on tab characters instead of commas. Everything else in the function call works identically to a CSV read.
sep and delimiter are exact aliases in pandas — they do the same thing. You will see both in code examples:
# These are identical:
df = pd.read_csv('data.tsv', sep='\t')
df = pd.read_csv('data.tsv', delimiter='\t')
Use whichever reads more clearly in your context. In most codebases, sep is more common for this use case.
If you are reading a file with a .txt extension that happens to be tab-separated, the same call works — pandas does not use the extension to determine the format, only the sep parameter:
df = pd.read_csv('export.txt', sep='\t')
The Most Common Mistake: Forgetting sep="\t"
If you call pd.read_csv('data.tsv') without sep='\t', pandas reads the entire row as a single column value. The DataFrame will have exactly one column, named after the first row of data, with the rest of the rows as string values containing tab characters.
You will see something like this in the output:
name age city 0 Alice 30 New York 1 Bob 25 Seattle
The column name literally contains characters and the data is unsplit. The fix is always the same: add sep='\t'.
A subtler version of this mistake: using sep=' ' inside double quotes in some contexts where backslash-t is not interpreted as a tab. In Python string literals, both '\t' and " " produce a tab character correctly. If you are passing the string from an environment variable or a config file, make sure the tab character is being passed through correctly.
Loading Compressed TSV.GZ Files
Many large TSV datasets are distributed as gzip-compressed files (.tsv.gz). pandas handles these natively:
df = pd.read_csv('data.tsv.gz', sep='\t', compression='gzip')
Or let pandas auto-detect the compression:
df = pd.read_csv('data.tsv.gz', sep='\t', compression='infer')
compression='infer' checks the file extension: .gz triggers gzip, .bz2 triggers bzip2, .zip triggers zip. This is convenient for pipelines that process files with varying compression.
For very large compressed files that exceed available memory, use chunked reading:
chunks = []
for chunk in pd.read_csv('large.tsv.gz', sep='\t', chunksize=100000):
# process chunk here
chunks.append(chunk)
df = pd.concat(chunks)
Each chunk is a DataFrame with 100,000 rows. Process and optionally filter each chunk before concatenating to keep memory usage manageable.
Encoding Issues with TSV Files
Scientific and database-exported TSV files are often UTF-8, but files from older systems may be in Latin-1, Windows-1252, or other encodings. If you see a UnicodeDecodeError, specify the encoding explicitly:
# For most European language data from Windows systems:
df = pd.read_csv('data.tsv', sep='\t', encoding='windows-1252')
# For Latin-1 (ISO-8859-1):
df = pd.read_csv('data.tsv', sep='\t', encoding='latin-1')
# If you do not know the encoding and want pandas to guess:
df = pd.read_csv('data.tsv', sep='\t', encoding_errors='replace')
encoding_errors='replace' substitutes a replacement character for bytes that cannot be decoded, instead of throwing an error. Useful for quickly inspecting data when you are not sure of the source encoding.
If you need to convert the TSV to CSV without Python — for sharing with a colleague or importing into a non-Python tool — the browser converter handles most common encodings without configuration.
Converting TSV to CSV with pandas
Once loaded, exporting to CSV is one line:
df = pd.read_csv('data.tsv', sep='\t')
df.to_csv('data.csv', index=False)
index=False prevents pandas from writing the DataFrame's integer index as an extra first column — a common source of an unexpected "Unnamed: 0" column when the file is opened later.
For large files where you want to stream rather than load the whole DataFrame into memory:
with open('data.tsv', 'r') as infile, open('data.csv', 'w') as outfile:
import csv
reader = csv.reader(infile, delimiter='\t')
writer = csv.writer(outfile)
writer.writerows(reader)
The csv module approach from the standard library is memory-efficient and applies proper RFC 4180 quoting without loading the full dataset.
For a no-code alternative that does the same thing in a browser, the no-code conversion guide compares all approaches including the browser tool, sed, and Python side by side.
Convert TSV to CSV Without Pandas — Instant Browser Tool
No Python environment needed. Drop a .tsv file and download a properly formatted CSV. Runs 100% in your browser.
Convert TSV to CSV FreeFrequently Asked Questions
Why does pd.read_csv show all TSV data in one column?
pandas uses a comma as the default delimiter. When reading a TSV file, you must specify sep="\t" — without it, pandas treats the entire row as a single value. Fix: pd.read_csv("file.tsv", sep="\t").
What is the difference between sep and delimiter in pandas read_csv?
They are identical — sep and delimiter are exact aliases. You can use either in your read_csv call. Most pandas documentation uses sep, but both are equally valid.
How do I read a tab-separated .txt file with pandas?
The same way as a .tsv file: pd.read_csv("file.txt", sep="\t"). Pandas determines the format from the sep parameter, not the file extension. A .txt file with tab-separated content loads identically to a .tsv file.
Can I convert TSV to CSV without installing pandas?
Yes. The browser-based TSV to CSV converter requires no Python installation. Drop your .tsv file in a browser tab and download the CSV. For larger datasets or automated pipelines, Python's built-in csv module (no additional install needed) also works: csv.reader with delimiter="\t" and csv.writer to output.

