Search code examples
pythonjupyter-notebookexport-to-csvfilenotfoundexceptionjupyter-console

How to connect your CSV file to Jupyter Notebook?


So I have a CSV file from google analytics called 'data-export' and I'm trying to use Python in Jupyter Notebook to basically open the file and then later, create charts for furhter analysis.

import pandas as pd
getCSV = pd.read_csv('data-export',skiprows=10,skipfooter=500,engine = 'python')
getCSV.head()

#error message
FileNotFoundError                         Traceback (most recent call last)
FileNotFoundError: [Errno 2] No such file or directory: 'data-export'

I tried using syntax I found online, however the error message keeps telling me filenotfound and no such file or directory. Can someone please explain exactly how I can get the code to read the file?


Solution

  • You need to give it the full path to the file on your local machine, not just the name of it. Most file paths look like this: C:\Users\yeetMan\Downloads\code\scratch.csv

    Go to the file in file explorer, click on it, and click "copy path". This will copy the full file path.

    Make sure to include the .csv at the end.