Ahmed ElAbbas
Ahmed ElAbbas

Reputation: 1

Trouble reading CSV file using pandas

I'm working on a data analysis project & I wanted to read data from CSV files using pandas. I read the first CSV file and It was fine but the second one gave me a UTF 8 encoding error. I exported the file to csv and encoded it to UTF-8 in the numbers spreadsheet app. However, the data frame is not in the expected format. Any idea why? code in Jupyter notebook

the original CSV file in numbers the original CSV file in numbers

Upvotes: 0

Views: 585

Answers (3)

buran
buran

Reputation: 14233

The file is semicolon-separated and also decimal is comma, not dot

df = pd.read_csv('mitb.csv', sep=';', decimal=',')

And Please do not upload images of code/data/errors..

Upvotes: 1

thomas
thomas

Reputation: 104

it looks like your file is semicolon separated not comma separated. To fix this you need to add the sep=';' parameter to pd.read_csv function.

pd.read_csv("mitb.csv", sep=';')

Upvotes: 1

ICEPower
ICEPower

Reputation: 21

Try adding the correct delimiter, in this case ";", to read the csv.

mitb = pd.read_csv('mitb.csv', sep=";")

Upvotes: 1

Related Questions