Hello, so I have a jupyter notebook in the data/processed folder and I want to access the json and csv file I have downloaded into the data/raw folder. I can’t seem to write the correct path for it.
data\
processed\
datacleaning.ipynb
raw\
getdata.ipynb
EXAMPLE.json
EXAMPLE.csv
src\
results.ipynb
import pandas as pd
import json
raw_data = open("./data/raw/EXAMPLE.json")
i got the FileNotFoundError: [Errno 2] No such file or directory: ‘./data/raw/EXAMPLE.json’
Anyone know what the correct path would be?
>Solution :
Let’s assume your project lives in the absolute folder /home/karo/projects/.
Your notebooks current directiory is /home/karo/projects/data/processed.
When you write
raw_data = open("./data/raw/EXAMPLE.json")
it will be resolved to
raw_data = open("/home/karo/projects/data/processed/data/raw/EXAMPLE.json")
As you can see that’s not an existing path.
You can either write:
raw_data = open("/home/karo/projects/data/raw/EXAMPLE.json")raw_data = open("../raw/EXAMPLE.json")
