(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

+1 vote
import pandas as pd
data=pd.read_csv("C:\Users\Welcome\Desktop\Sales.csv",encoding='latin1')
print(data.head())
Dec 28, 2019 in Python by Abhishek
• 130 points
432 views

1 answer to this question.

0 votes

You are getting this error because you are using the path to the file as a string. Change that line to something like this:

pandas.read_csv(r"C:\Users\Welcome\Desktop\Sales.csv",encoding='latin1')

Hope it helps :)

answered Dec 31, 2019 by Kalgi
• 51,160 points

Related Questions In Python

0 votes
2 answers

Error: Speech to Text Codec cannot decode the bytes in position

import speech_recognition as sr r = sr.Recognizer() audio ='C\Users\Desktop\audiofile1.wav' with ...READ MORE

answered Nov 27, 2018 in Python by Nabarupa Das
264 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
1,589 views
+1 vote
1 answer

UnicodeDecodeError: "utf-8" codec can't decode byte in position : invalid start byte

You have to use the encoding as latin1 ...READ MORE

answered Jul 23, 2019 in Python by Kunal
7,274 views
+1 vote
3 answers

Write a for loop that prints all elements of a list and their position in the list. a = [4,7,3,2,5,9]

Try using this question by list comprehension: a=[4,7,3,2,5,9] print([x for ...READ MORE

answered Dec 8, 2019 in Python by vinaykumar
• 160 points
1,099 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 556 views
0 votes
0 answers
+4 votes
6 answers
+7 votes
8 answers

Difference for string comparison in Python: 'is' vs. ==

If we use "==" means both variables ...READ MORE

answered Sep 3, 2018 in Python by Parul Raheja
514 views
0 votes
1 answer

Python error "raise CommandFailedError(args) bench.utils.CommandFailedError: (’–site’, ‘all’, ‘migrate’)"

Install pyopenssl to your python pip install pyopenssl ...READ MORE

answered Aug 5, 2019 in Python by Kalgi
• 51,160 points
101 views