Skip to content
Advertisement

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

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

Here is the file format from the .csv :

JavaScript

here is how get it :

JavaScript

Now when I print the file I get that :

JavaScript

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

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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement