Uncategorized

How do i get python to read my excel file?


I am trying to read information from my excel file but continue to run into the following error: FileNotFoundError: [Errno 2] No such file or directory: ‘OptionsBook.xlsx’.

I have tried both pandas and openpyxl to do this but both lead to the same error. In my code I have also tried iterating through my files to see if it python even recognizes the file but i know that it does.

Here is my current snippet of code that I am using:

file = os.listdir('C:/Users/DUMMY/OneDrive/Desktop')
    for f in file:
        print(f)
dataframe = xl.load_workbook("OptionsBook.xlsx")
dataframe1 = dataframe.active

Whenever I do that I do end up seeing all of the files on my desktop and the OptionsBook is one of them. But ultimately whenever I try one of the many tricks to read the excel file it errors saying that there is no such directory or file. Is there a problem with OneDrive or am i missing something else?



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *