0

I'm trying to read in the following tab separated data into pandas: test.csv:

col_a\tcol_b\tcol_c\tcol_d 4\t3\t2\t1
4\t3\t2\t1

I tried import test.csv in different ways as follows but not success:

pd.read_csv('test.csv',delimeter='\t')
pd.read_csv('test.csv',sep='\t')
pd.read_csv('test.csv', sep=r'\\t', engine='python')

The resulting dataframe has 1 column. The \t is not recognized as tab.

Thanks in advance for your help.

1 Answers1

0

I think the r'' suffix is used in the wrong way.

try:

pd.read_csv('test.csv',sep='\\t') or pd.read_csv('test.csv', sep=r'\t')

Here an olt topic: python pandas read_csv not recognizing \t in tab delimited file

Glauco
  • 1,385
  • 2
  • 10
  • 20