0
for files in os.listdir(dir):
    if files[-4::] == 'xlsx':
        file_1 = pd.ExcelFile(os.path.join(dir,files))
        print('Path of File: ', os.path.join(dir,files))
        print('Student Number: ', pd.read_excel(file_1, sheet_name=0).iloc[0,1])
        for names in sheets_names:
            sheet = file_1.sheet_names.index(names)
            print('Sheet: ', file_1.sheet_names[sheet])
            file_original = pd.read_excel(file_1, sheet_name=sheet)
            file_copy = file_original.copy()

I have 13 excel files in a folder i want to read and write in ascending order (student number) . i have used following code but it shows error engine must give manually

aaossa
  • 3,763
  • 2
  • 21
  • 34
  • Does this answer your question? [PANDAS & glob - Excel file format cannot be determined, you must specify an engine manually](https://stackoverflow.com/questions/68478097/pandas-glob-excel-file-format-cannot-be-determined-you-must-specify-an-engi) – aaossa Mar 04 '22 at 14:55

1 Answers1

0

I think that the error is related normally with temporary files created when you openned your file in Excel. they are usually hidden. Try to enable Show Hidden Files in folder option then you can find them in your explorer.

You will find like :

~$Filename.xlsx

delete it, run it back.

Here is a description about these files.

Make sure also that you're using the correct reader.

#For xlsx files
if file_extension == 'xlsx':
    df = pd.read_excel(file.read(), engine='openpyxl')
#For xls files
elif file_extension == 'xls':
    df = pd.read_excel(file.read())