I a importing a .csv
file in python with pandas.
Here is the file format from the .csv
:
JavaScript
x
4
1
a1;b1;c1;d1;e1;
2
a2;b2;c2;d2;e2;
3
..
4
here is how get it :
JavaScript
1
4
1
from pandas import *
2
csv_path = "C:...."
3
data = read_csv(csv_path)
4
Now when I print the file I get that :
JavaScript
1
3
1
0 a1;b1;c1;d1;e1;
2
1 a2;b2;c2;d2;e2;
3
And so on… So I need help to read the file and split the values in columns, with the semi color character ;
.
Advertisement
Answer
read_csv
takes a sep
param, in your case just pass sep=';'
like so:
JavaScript
1
2
1
data = read_csv(csv_path, sep=';')
2
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.