Webmax
Webmax

Reputation: 43

utf-8 and latin-1 won't work while reading a csv file with pandas

I am trying to read a CSV file which includes French characters (like é, à, etc.) and email addresses with pandas.

Encoding with utf-8 gives an error. Encoding with latin-1 eliminates my é.

Any idea what encoding I should use ?

Thanks, Chris

Upvotes: 3

Views: 10492

Answers (2)

BSP
BSP

Reputation: 775

pd.read_csv(csv_file, encoding = 'iso-8859-1')

where 'iso-8859-1' is the encoding needed to properly represent languages from occidental Europe including France

Upvotes: 5

Sebastien D
Sebastien D

Reputation: 4482

Try the following

#! /usr/bin/python
# coding: utf-8
import pandas
file_content = open('some_file.csv')
data = pandas.read_csv(file_content, encoding='utf-8', quotechar='"', 
delimiter=';')

Upvotes: 0

Related Questions