How to parse tsv file with python?
import pandas as pd
data = pd.read_csv ("file.tsv", sep = '\t')
Just use the csv module. It knows about all the possible corner cases in CSV files like new lines in quoted fields. And it can delimit on tabs.
with open("file.tsv") as fd:
rd = csv.reader(fd, delimiter="\t", quotechar='"')
for row in rd:
print(row)
will correctly output:
['111', '222', '333', 'aaa']
['444', '555', '666', 'bb\nb']