0

I have used

import pandas as pd
data = pd.read_csv('C:\Users\Dell\Downloads\8. Netflix Dataset.csv') 

but then it is showing this

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

After this I have also used

data = pd.read_csv(r"C:\Users\Dell\Downloads\8. Netflix Dataset.csv")

but it then shows

FileNotFoundError: [Errno 2]
No such file or directory: 'C:\\Users\\Dell\\Downloads\\8. Netflix Dataset.csv'
Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175
  • 3
    The first error was due to the lack of escaping the slashes. The second error is simply that the file is not there. Are you sure the file is where it is and is accessible by the user running jupyter? – nonDucor Jun 18 '22 at 19:14
  • 1
    You can always use forward slashes to refer to files within python. This is often more reliable and less confusing because backslashes are the escape character in python, and if the string gets parsed more than once you can end up needing to double-escape the slashes. It's a whole mess. But I think that's separate from your issue. – Michael Delgado Jun 18 '22 at 19:14
  • 1
    Right. It is a little known fact that EVERY Windows API accepts forward slashes in file names. The only exception is the command line itself. – Tim Roberts Jun 18 '22 at 19:16
  • @Nikita Sing - Welcome to stack overflow! We've edited your question to introduce [code block formatting](/help/formatting) and to drop some of the tags - [tag:jupyterhub] refers to a multi-user jupyter server, and [tag:csv.reader] refers to a specific engine for reading CSV files (not pandas). Generally, unless you're specifically asking about jupyter/jupyterlab, you don't need to add that tag if the question is just about python. You could add the [tag:pandas] tag, but in this case, the question comes down to just string formatting :). Thanks for jumping in and participating in the site! – Michael Delgado Jun 18 '22 at 19:26
  • Since you're in a jupyter notebook, you can use the `ls` command to make sure the file is there. Try `ls 'C:/Users/Dell/Downloads/8. Netflix Dataset.csv'`. If that raises an error, you know the file might not be *exactly* at that path. – Michael Delgado Jun 18 '22 at 19:28
  • yes it is totally accessible that i why I jut dont understand why it is happening when the address is totally correct – Nikita Singh Jun 18 '22 at 19:34

0 Answers0