Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python reading in multi-column tsv file with row numbers

What is the cleanest way of reading in a multi-column tsv file in python with headers, but where the first column has no header and instead contains the row numbers for each row?

This is apparently a common format from files coming from R data frames.

Example:

    A      B  C
1   a1     b1 c1
2   a2     b2 c2
3   a3     b3 c3

Any ideas?

like image 216
719016 Avatar asked Sep 09 '14 15:09

719016


1 Answers

df = DataFrame.from_csv("tsv.tsv", sep="\t") is deprecated since version 0.21.0

df = pd.read_csv("tsv.tsv", sep="\t") is the way to go

like image 63
Pil Kwon Avatar answered Oct 09 '22 12:10

Pil Kwon