Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Pandas read_excel returns empty Dataframe

Tags:

python

Reading a simple xls returning empty dataframe, can't figure it out for the life of me:

path = ('c:/Users/Desktop/Stuff/Ready')
files = os.listdir(path)
print(files)

files_xlsx = [f for f in files if f[-3:] == 'xlsx']

readyorders = pd.DataFrame()
for filename in files_xlsx:
    with open(os.path.join(path, filename)) as f:
        data = pd.read_excel(f)
        readyorders = readyorders.append(data)

print(readyorders)

The excel is just two simple columns...is it just too early in the day?

like image 343
gbcuzi Avatar asked Jul 20 '26 02:07

gbcuzi


1 Answers

I had a similar issue and it turns out that there are TWO types of XLSX: "Excel Workbook" (at the top of the list in the image below) and "Strict Open XML Spreadsheet" (with the checkmark). The latter returns an empty spreadsheet in pandas, so use the Excel Workbook (.xlsx) and you won't have problems.

enter image description here

like image 200
Nic Scozzaro Avatar answered Jul 21 '26 16:07

Nic Scozzaro