adhg adhg - 2 months ago 10
Python Question

How to access the project root folder

Below is a screenshot of my project. While I can access my

_files_inner
folder quite easily with
pd.read_csv("./_files_inner/games.csv")
I find it tricky to access my 'root' folder
_files


if you see my project explorer, I'm trying to access the
_files
but without specifying the absolute path (i.e.,
C:\\Users\\adhg\\dev\\py\\_files\\games.csv
) because other developer have different path.

Question: how to access the root
_files
folder with something like this one (doesn't work)
pd.read_csv("./_files/games.csv")
:

import pandas as pd

csv_result = pd.read_csv("./_files/games.csv") #will not work
csv_result = pd.read_csv("./_files_inner/games.csv") #works

print csv_result


enter image description here

Answer

try using ../_files_inner/games.csv