Out of memory while reading excel file

Mahmood Naderan nt_mahmood at yahoo.com
Thu May 11 02:03:52 EDT 2017


Hi,
I used the old fashion coding style to create a matrix and read/add the cells.

W = load_workbook(fname, read_only = True)
p = W.worksheets[0]
m = p.max_row
n = p.max_column
arr = np.empty((m, n), dtype=object)
for r in range(1, m):
    for c in range(1, n):
              d = p.cell(row=r, column=c)
              arr[r, c] = d.value


However, the operation is very slow. I printed row number to see how things are going. It took 2 minutes to add 200 rows and about 10 minutes to add the next 200 rows. 
 
Regards,
Mahmood



More information about the Python-list mailing list