Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open csv from different directory in python

Im trying to open a csv file as followed

My ipynb-file is in the following directory -> /data/filename.ipynb where as my csv file is in the following directory -> /data/preprocessed/processed_data.csv

When i try to open the file with the following code:

df = pd.read_csv('/preprocessed/processed_data.csv')

I get an exception that the file doesn't exist. Somehow I think I didn't quite understand how the directories work. Please help, thanks.


1 Answers

try this-

df = pd.read_csv('preprocessed/processed_data.csv')
like image 187
Tal Folkman Avatar answered Mar 01 '26 18:03

Tal Folkman



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!