Issue loading large .xlsx file with read_only
Trying to load a large .xlsx file - using the standard 'load_workbook' method with 'data_only=True` param it takes ages.
So instead I'm trying to load with read_only=True
which seemingly loads fast, but when I look at the data, only the first cell of the active sheet has been loaded?
Here's my code (with the URL to the file so you can try it yourself):
import requests
from io import BytesIO
import pandas as pd
from openpyxl import load_workbook
import itertools
url = 'https://www.nlog.nl/sites/default/files/thematische_data/nlog_dirstelsel.xlsx'
def get_file_data(url):
response = requests.get(url)
f = BytesIO()
for chunk in response.iter_content(chunk_size=1024):
f.write(chunk)
f.seek(0)
return f
wb = load_workbook(get_file_data(url), read_only=True)
ws = wb.active
data = ws.values
if I try:
[r for r in ws.rows]
or:
[d for d in data]
I just get the contents of cell A1 in the active sheet.
I do get an error:
UserWarning: Workbook contains no default style, apply openpyxl's default
warn("Workbook contains no default style, apply openpyxl's default")
But I think this is a soft error?
Any ideas?