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'])
6 days ago in Python by Kamal
16 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

add the following line on top of your python code:

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

Also, avoid using non-ascii quotations.

answered 6 days ago by Rhea

Related Questions In Python

+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
• 56,140 points
43 views
0 votes
1 answer

How can I print variable and string on same line in Python?

Use , to separate strings and variables while printing: print ...READ MORE

answered Sep 17, 2018 in Python by Priyaj
• 56,140 points
37 views
0 votes
1 answer
0 votes
1 answer

How to handle AssertionError in Python and find out which line or statement it occurred on?

Use the traceback module: import sys import traceback try: ...READ MORE

answered Dec 17, 2018 in Python by charlie_brown
• 7,710 points
276 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
56 views
+4 votes
6 answers
0 votes
1 answer

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

use the sep argument of to_csv, to delimit by a tab: df.to_csv(file_name, ...READ MORE

answered 6 days ago in Python by Rhea
16 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
• 10,860 points
78 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.