Answer the question
In order to leave comments, you need to log in
How to fix openpyxl memory error with ws.insert_rows(2246)?
Hello.
There is an xlsx file. 190 KB. About 3000 rows and 10 columns. it contains formulas and values. It has this error. (In another smaller file, I did it without errors)
When creating a new row ws.insert_rows(2246) the script hangs for about a minute, then gives this error:
:: Exception occurred
Traceback (most recent call last):
File "C:/YandexDisk/бизнес/Python/proverkaSoobchenii/remove_placmant_ads.py", line 27, in remove_placemant_ads
replacement_ads1(product_and_site=q2, account_category_is_phones_in_youla_f2=account_category_is_phones_in_youla_f2, category_limit_for_game_telephone_in_youla_f2=category_limit_for_game_telephone_in_youla_f2)
File "C:\YandexDisk\бизнес\Python\proverkaSoobchenii\placemant_ads.py", line 246, in replacement_ads1
ws.insert_rows(2246)
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 694, in insert_rows
self._move_cells(min_row=idx, offset=amount, row_or_col="row")
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 679, in _move_cells
cells = list(cells)
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 445, in _cells_by_row
yield tuple(cells)
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 441, in <genexpr>
cells = (self.cell(row=row, column=column) for column in range(min_col, max_col + 1))
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 238, in cell
cell = self._get_cell(row, column)
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 253, in _get_cell
self._add_cell(cell)
File "C:\Users\первый\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 264, in _add_cell
self._cells[(row, column)] = cell
MemoryError
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question