1

I can't import a csv file onto the jupyter notebook i've tried all the solutions on the site prefixing the dir with r, using backslashes, forward slashes and double backslashes. what do i do? this is the code:

import pandas as pd

df = pd.read_csv(r"C:\Users\sidha\main.csv")
picklerick
  • 11
  • 2
  • try giving the complete path. Something like `C:\Users\sidha\main.csv`. What error are you getting? – moys Jun 10 '20 at 05:28
  • File "", line 2 df = pd.read_csv(":\Users\sidha\main.csv") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: truncated \UXXXXXXXX escape – picklerick Jun 10 '20 at 05:32
  • Try to check you are giving the file path correctly without any letters mistakes. – Aditya Shende Jun 10 '20 at 05:33
  • sorry i messed up the question but i did give the complete path: – picklerick Jun 10 '20 at 05:34
  • You could try with "\\" instead of "r": `df = pd.read_csv("C:\\Users\\sidha\\main.csv")` -- Never mind, saw you already tried. – vodbeke Jun 10 '20 at 05:53
  • have u checked this thread?:https://stackoverflow.com/a/1347854/11045279 – Aditya Patnaik Jun 10 '20 at 05:55
  • Have you tried putting the *.csv directly in the root of your project (same folder from where you started the jupyter notebook) and passing just the name of it? Something like `df=pd.read_csv("news.csv")` should work easier. – John Calchon Jun 10 '20 at 15:09

0 Answers0