My program has the next structure:
|---main.py
|---home
|----read.csv
|----importer.py
main.py has the next code:
from home import importer as imp
imp.load()
importer.py has the next code:
import pandas as pd
import sys
def load():
arch = pd.read_csv("read.csv")
print arch
if __name__ == '__main__':
load()
and read.csv is any csv, it is for example
h,k
3,4
5,6
When I run importer.py, it runs ok, and that's because read.csv is in the current path.
But when I try to run main.py, it throws an exception, because it can't find read.csv. It's because read.csv is not in the current path.
I need it works in both modes, and the solution would be to append the home path to the python main program.
I tried to do this sys.path.append(os.path.join(os.getcwd(), "home")) but it did'nt work.
Any idea?
loadtake in a path parameter and passing in a absolute path every time.__init__.pyin your home directory?