Python Forum
(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \
#4
Check your path Path and file.

Here a little basic about Path and file as i think you struggle with that.
Navigate training in cmd and check file,this way you now that path is correct.
Then open file Pandas.
cmd:
Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. Med enerett.

# Navigate with cd
C:\Windows\System32>cd\
C:\>cd foo1

# look at files in folder
C:\foo1>dir
 Volume in drive C has no label.
 Volume Serial Number is EED7-45CC

 Directory of C:\foo1

11.05.2018  12:46    <DIR>          .
11.05.2018  12:46    <DIR>          ..
13.09.2017  22:03                 0 cd1.txt
11.05.2018  12:40                73 my_csv.csv
               2 File(s)             73 bytes
               2 Dir(s)  66 910 232 576 bytes free

# Open file in folder
C:\foo1>type my_csv.csv
Student,Age,Subject
Adam,13,Maths
Alex,14,English
Shawn,15,Geography
cmd Anaconda:
G:\Anaconda3>python
Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>>
>>> df = pd.read_csv(r'C:\foo1\my_csv.csv')
>>> df
  Student  Age    Subject
0    Adam   13      Maths
1    Alex   14    English
2   Shawn   15  Geography
>>>
Then it also work the same in Jupyter NoteBook.
[Image: XNaK6F.jpg]
Reply


Messages In This Thread
RE: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \ - by snippsat - May-11-2018, 11:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fatal Python error: initfsencoding: unable to load the file system codec gauravbhardwajee 12 28,370 Apr-30-2020, 07:45 PM
Last Post: barrpath

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020