Amarjot Singh
Amarjot Singh

Reputation: 70

Handling special characters (extended ascii) not displayed correctly when reading via pandas.read_csv()

I have a csv file that has extended ASCII characters like -> "Néw" , when I try to read this file and output the rows I get special character for e.g the above becomes -> "N�w".

I am using below command to read the file

df = pd.read_csv("temp.csv")
df.head(5)

Upvotes: 1

Views: 366

Answers (1)

Infinite
Infinite

Reputation: 764

read_csv has a parameter 'encoding' which you would need to add to your code to get the string in text correctly .

Could you try using below and check if it works

df = pd.read_csv("temp.csv", encoding='utf-8')
df.head(5)

For checking list of all standard python encoding check this link- here

Upvotes: 1

Related Questions