Reputation: 197
I'm trying to create an excel file and try to open it and perform some operations on that data.
file_path = 'd:/files/'
file_folder = 'new_files'
file_name = 'sample.xlsx'
def export(data):
data.to_excel("{}/{}".format(downloadpath(), downloadfile()), index=False)
excel_data = open("{}/{}".format(downloadpath(), downloadfile()), 'rb')
# excel_data_operations
def downloadpath():
PATH = os.path.join(file_path, file_folder)
if not os.path.isdir(PATH):
return os.makedirs(PATH)
return PATH
def downloadfile():
return file_name
I'm trying to do this, but getting end up with
FileNotFoundError: [Errno 2] No such file or directory: 'None/sample.xlsx'
Upvotes: 0
Views: 38
Reputation: 13478
In the definition of downloadpath
:
return os.makedirs(PATH)
os.makedirs(PATH)
Upvotes: 1
Reputation: 250
The string 'd:/files/' says that you use windows. In windows, the file path should use backslashes '\'. Try to change the string to d:\files\
Upvotes: 0