Read csv adds \t to each column and value

Viewed 48

When i read my csv

cs = pd.read_csv(r'file.csv',encoding='utf-8')

it adds a \t to each column and value except of numbers (so to all strings) I downloaded the file from the same source where i have downloaded previous files and there it didn't add it. I have the same reading command as always

     \tamplitude_id       \tuser_id \tcity \tcountry  ...                                   \tgp:utm_content \tgp:utm_medium \tgp:utm_source               \tgp:utm_term
0      123456789    123456789     \t        \t  ...                                                 \t              \t              \t                          \t
1      123456789  123456789     \t        \t  ...                                                 \t              \tpaid                \t                          \t

how can I read it without the \t

1 Answers

When you see "\t" after reading a file it represents tab and in CSV it usually represents a different column in the same row

so adding sep = '\t' to your original command should do the trick:

cs = pd.read_csv(r'file.csv',sep = '\t' ,encoding='utf-8')

If you have any questions feel free to ask me in the comments.

Related