3

I have a script that edits an xlsx file I've been running weekly successfully for a year and a half, up until last week when this error started to occur: Excel file format cannot be determined, you must specify an engine manually.

df = pd.read_excel("test.xlsx", keep_default_na=False, sheet_name=sheet_name) is the line causing an issue. I have xlrd version 1.2.0 installed, since xlsx support was removed later. I've tried using different directories too, to no avail.

edit: specifying the engine as "xlrd" gives me the error: expected str, bytes or os.PathLike object, not NoneType

specifying engin as "openpyxl" gives the error: File is not a zip file

None of this even works when I used a .xls file either

edit2: Okay so I created a blank spreadsheet and it's not throwing that error anymore (Just an error due to the fact that it's blank obv). What could cause this?

Amon
  • 2,725
  • 5
  • 30
  • 52
  • 1
    did you try to specify the `engine` as the error explained? you can test by adding the parameter `engine='xlrd'` or maybe `engine='openpyxl'` in the `read_excel` – Ben.T Oct 08 '21 at 19:37
  • 1
    Possible [duplicate](https://stackoverflow.com/questions/68478097/pandas-glob-excel-file-format-cannot-be-determined-you-must-specify-an-engi) – ako Oct 08 '21 at 19:44
  • 1
    @Ben.T Hey thanks for the reply, yes I've tried those. Both have given me errors. I added an edit – Amon Oct 08 '21 at 19:51
  • @ako I've looked at that post as well. There's no hidden files there, I even placed the file in a different directory – Amon Oct 08 '21 at 19:52
  • Okay so I created a blank spreadsheet and it's not throwing that error anymore (Just an error due to the fact that it's blank obv). What could cause this? – Amon Oct 08 '21 at 20:20
  • For me the problem was that the file itself was not properly created: https://stackoverflow.com/q/73120629/12934163 – TiTo Oct 12 '22 at 08:32

0 Answers0