How to read a file with a semi colon separator in pandas

Tags: , ,

I a importing a .csv file in python with pandas.

Here is the file format from the .csv :


here is how get it :

from pandas import *
csv_path = "C:...."
data = read_csv(csv_path)

Now when I print the file I get that :

0  a1;b1;c1;d1;e1;...
1  a2;b2;c2;d2;e2;...   

And so on… So I need help to read the file and split the values in columns, with the semi color character ;.


read_csv takes a sep param, in your case just pass sep=';' like so:

data = read_csv(csv_path, sep=';')

The reason it failed in your case is that the default value is ',' so it scrunched up all the columns as a single column entry.

Source: stackoverflow