Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing DataFrames - no such file or directory

I am trying to import a csv file as a dataframe into a Jupyter notebook.

rest_relation = pd.read_csv('store_id_relation.csv', delimiter=',')

But I get this error

FileNotFoundError: [Errno 2] No such file or directory: 'store_id_relation.csv'

The store_id_relation.csv is definitely in the data folder, and I have tried adding data\ to the file location but I get the same error. Whats going wrong here?

enter image description here

like image 782
Scott Adamson Avatar asked Jul 25 '26 04:07

Scott Adamson


1 Answers

Using the filename only works if the file is located in the current working directory. You can check the current working directory using os.getcwd().

import os
current_directory = os.getcwd()
print(current_directory) 

One way you can make your code work is to change the working directory to the one where the file is located.

os.chdir("Path to wherever your file is located")

Or you can substitute the filename with the full path to the file. The full path would look something like C:\Users\Documents\store_id_relation.csv.

like image 143
rajsuryan Avatar answered Jul 27 '26 03:07

rajsuryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!