0

I am doing something very simple, converting an excel spreadsheet to a pandas dataframe, but for some reason I keep getting this error: No such file or directory....

I have the file downloaded and saved to my computer and restarted my program, so I don't know what could be wrong. Any clue what's up?

Here is my code...

import pandas as pd 

file_name ="file.xlsx"


dataframe = pd.read_excel(file_name)
print(dataframe)

1 Answers1

1

You should have your "file.xlsx" in the same directory from where you call 'python' or specify full path to it (e.g. 'C:\file.xlsx' or '/home/user/file.xlsx')

  • 1
    when I do that I get this error... file_name = 'C:\Users\samfe\Downloads\Recent_LPL_Transactions_10-13-2020.xlsx' ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape – Samuel DiSorbo Oct 13 '20 at 22:59
  • 1
    @SamuelDiSorbo please see this answer: https://stackoverflow.com/a/46011113/2950818 – user2950818 Oct 14 '20 at 00:07