I am trying to speed up the process of writing data to an excel file using python in my code. The PyExcelerate module has a good benchmark in terms of writing bulk data to files compared to other python modules.
- Dimensions: Rows = 10000 Cols = 50
Times:
- pyexcelerate : 10.11
- xlwt : 15.67
- xlsxwriter (optimised): 19.70
- xlsxwriter : 23.50
- openpyxl (optimised): 95.82
- openpyxl : 95.90
Also, writing data in batches improves the time taken to write furthermore. See link below.
Now, what I am trying to do is add data to a list as and when it is computed, and when the list size is equal to 500 or when 500 rows of data have been computed, write to the file.
wb = Workbook()
ws = wb.new_sheet("test")
ws.range("B2", "C3").value = [[1, 2], [3, 4]]
wb.save("output.xlsx")
Is there a way that we could append the data for 500 rows in a batch?