0

Cannot determine why Jupyter cannot load my csv file.. The code I have in Jupyter cell is pretty simple

    import pandas as pd 
    df = pd.read_csv(r"purchases.csv")

getting the error below

CParserError enter image description here

Traceback (most recent call last)
<ipython-input-45-139a6a5372f2> in <module>()
      3 
      4 
----> 5 df = pd.read_csv(r"purchases.csv")
      6 df
      7 

Name of Notebook is Pandas Tet s

In my directory, I can see the csv file- purchases.csv Plz advise - have spent a lot of time and I cannot figure it out.

I am taking coursera course and downloaded their notes. I can read mpg.csv and their other files. Do I have to do anything special on files which I create. I have searched online and cannot determine a solution. Thx in advance

7
  • why use raw string ? Commented Jul 27, 2020 at 4:04
  • For example, this article may be helpful. How to specify file path in jupyter notebook Commented Jul 27, 2020 at 4:07
  • Hi kunif.. tried that link and no success Commented Jul 27, 2020 at 4:16
  • Hi Philip.. Have tried using c:\\....\\purchases.csv, c:\purchases.csv, in single quotes ,double quotes and no success Commented Jul 27, 2020 at 4:18
  • Hello. the r string use if you use path with backslash for example this path c:\purchases.csv but if your notebook file is in the same folder with the purchases.csv file, then you just need the filename instead of the full path. Try df = pd.read_csv('purchases.csv') Commented Jul 27, 2020 at 4:23

1 Answer 1

0

The following should work since the csv file is in the same folder as the ipynb file.

    import pandas as pd
    df = pd.read_csv("purchases.csv")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.