0

Please bear with me as I'm new. I'm currently using Spyder on Anaconda Navigator. Trying to read an excel file from a folder in my desktop like this:

import pandas as pd
Dark_Maple_1 = pd.read_excel(r'C:\\Users\maiazhang\Desktop\CNN Data\Dark Maple\Dark Maple (1).xslx')

But I keep getting this error: FileNotFoundError.

I've triple checked that this is the correct path, so I'm confused. I guess it has something to do with me being on Anaconda Navigator. I've tried changing the working directory and even tried just reading a normal txt file with the same error. Any advice would be much appreciated.

  • Try removing the extra backslash at the front `"C:\Users\..."`. Are you running on Windows? The other paths in the traceback look unixy. You could also just use forward slashes and skip the raw string completely. – tdelaney Aug 09 '22 at 04:13
  • @tdelaney , I tried every combination I could think of and still couldn't reproduce the error (on my machine at least) – Michael S. Aug 09 '22 at 05:01
  • Tried removing backslashes/using forward slashes too. :( – LargeMuscle2 Aug 09 '22 at 14:53

1 Answers1

0

xslx is not a file type (at least I'm betting not the one you want). Change it to xlsx and you should be fine.

After looking at your traceback error, it does say xlsx so something must be wrong either in your code's directory or your actual file's name. I have tried to recreate your error in both Jupyter Notebook (launched from terminal), Jupyter Lab (from Anaconda Navigator), Jupyter Notebook (from Anaconda Navigator) and Spyder (launched from Anaconda Navigator) and cannot recreate your error (unless I mistype xslx either in my pandas read call or renaming my file)

Michael S.
  • 3,050
  • 4
  • 19
  • 34
  • Thanks for picking up on that! I tried again with the correct "xlsx" and it's still throwing this error. If I can't get rid of it, do you have any recommendations as to what I should do? – LargeMuscle2 Aug 09 '22 at 14:49
  • My recommendation is to create a Jupyter Notebook (.ipynb) in a folder. Then place the excel file in that same exact folder. Open your Jupyter Notebook, type your above code without the directory (so just `pd.read_excel('Dark Maple (1).xlsx')` ) and see if it opens. If it does, then your path was wrong in your original code. If it doesn't, then I don't know what the problem is. Maybe something with Spyder. [Try the answers here](https://stackoverflow.com/a/71992227/4458369) and see if any of them work (I have no experience in Spyder) – Michael S. Aug 09 '22 at 15:05