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
20,481 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.

Hope this helps!!

If you need to know more about Python, join Python online course today.

Thanks!

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
482 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, 2020 in Python by Nishant
• 210 points
2,560 views
0 votes
1 answer

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

I have the same issue and is ...READ MORE

answered Sep 6, 2020 in Python by anonymous
7,041 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,007 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,387 views
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
13,221 views
0 votes
2 answers

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

readline function help to  read line in ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 580 points
1,428 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP