Last answered:

02 Dec 2021

Posted on:

02 Dec 2021

0

Problems related to importing or exporting *.csv files.

I have Problems related to importing or exporting *.csv files.

1 answers ( 0 marked as helpful)
Posted on:

02 Dec 2021

0

Users of any operating system:

For those of you who feel comfortable in using more advanced bits of code, here’s another way of dealing with this problem.

To retrieve the path to the directory where the notebook file you’ve been working on has been stored and where new files would be automatically saved, you need to execute the following lines of code.





import os, inspect

 

if '__file__' not in locals():

 

fx = inspect.getframeinfo(inspect.currentframe())[0]

 

else:

 

fx = __file__

 

os_dir = os.path.dirname(os.path.abspath(fx))

 

print(os_dir)

 

Having assigned the correct value to os_dir, all references to files could be represented as



mydata_01.to_csv(os.path.join(os_dir,"example_01.csv"))

Submit an answer