I am using Pandas on Mac, to read and write a CSV file, and the weird thing is when using full path, it has error and when using just a file name, it works. I post my code w
Try using os.path.join()
.
import os
(...)
output_filename = 'newMaster.csv'
output_path = os.path.join('Downloads', output_filename)
(...)
sourceDf.to_csv(output_path)
Use the same methodology to point pandas.read_csv()
in the right direction.
You didn't specify python version.
On 3.4 you can use pathlib, otherwise use os.path.join()
or quoting:
sourceDf.to_csv(r'~/Downloads/newMaster.csv')
Notice the r. The problem is that /n is newline, which is not allowed in a path.