Python Error "SyntaxError: Non-ASCII character '\xe2' in file C:/path/ on line 3, but no encoding declared"

0 votes

I'm trying to execute a code and I get the following error

SyntaxError: Non-ASCII character '\xe2' in file C:/path/ on line 3, but no encoding declared
import pandas as pd

df = pd.read_csv(“C:\Users\Kamal\Desktop\Desktop\datasets\ex.xls”)

for index, row in df.iterrows():
    print (row['email'])
Jun 13, 2019 in Python by Kamal
1,854 views

1 answer to this question.

0 votes

add the following line on top of your python code:

# -*- coding: utf-8 -*-

Also, avoid using non-ascii quotations.

answered Jun 13, 2019 by Rhea

Related Questions In Python

0 votes
1 answer

Enter a 1-10, each on a new line in a file - python

Try something like this: i=1 for i in range(10): ...READ MORE

answered Jun 20, 2019 in Python by Greg
42 views
0 votes
0 answers

I am trying to install PyBase64 on my python 3.8. But I end up with the following error:

$ pip install pybase ERROR: Could not find ...READ MORE

Mar 24 in Python by Nishant
• 140 points
154 views
0 votes
0 answers

I am trying to install os-win on my python 3.8. But I end up with the following error:

ERROR: Command errored out with exit status ...READ MORE

Mar 24 in Python by Nishant
• 140 points
134 views
+1 vote
1 answer

Reading a large file, line by line in Python

The correct, fully Pythonic way to read ...READ MORE

answered Aug 21, 2018 in Python by Priyaj
• 57,530 points
90 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 754 views
0 votes
0 answers
+4 votes
6 answers
0 votes
2 answers

Python Error "UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)"

import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with ...READ MORE

answered Jun 28, 2019 in Python by anonymous
2,425 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,230 points
183 views