0

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'

2 Answers 2

1

In the definition of downloadpath:

  • replace return os.makedirs(PATH)
  • with os.makedirs(PATH)
Sign up to request clarification or add additional context in comments.

Comments

0

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\

3 Comments

I don't think its a / problem.
You return os.makedirs(PATH). This function returns None. This is definitely the problem
just remove 'return' before the 'os.makedirs(PATH)'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.