Reputation: 21
I'm using openpyxl for Python 2.7 to open and then modify a existing .xlsx file. This excel file has about 2500 columns and just 10 rows. The problem is openpyxl took to long to load the file (almost 1 Minute). Is there anyway to speed up the loading process of openpyxl. From other Threads I found some tips with read_only and write_only. But i have to read and write excel at the same time, so i can't apply this tips for me. Does anyone have any Suggestion. Thanks you very much
Upvotes: 0
Views: 2147
Reputation: 21
I had the same issue and found that while i was getting reasonable times initially (opening and closing was taking maybe 2-3 seconds), this suddenly increased to over a minute. I had introduced logging, so thought that may have been the cause, but after commenting this out, there was still a long delay
I copied the data from the Excel spreadsheet and just saved to a new excel spreadsheet which fixed it for me. Seems like it must have got corrupted somehow.
Note - saving the same filename as another filename didn't work, neither did saving the same filename on a local drive.
Upvotes: 0
Reputation: 39
I do not know what you need to do with the Excel file, but I would try opening the .xmls file as Pandas DataFrame:
import pandas as pd
df = pd.ExcelFile('file path')
Upvotes: -1