0

I'm new to Python and using openpyxl.

I've learned how to write and read and exact cell using ws.cell(row=1, column=1).value = something but what I want now is a while cycle where it reads all the values from one column and write in another column a value that I get from a function. When I try to do so instead of using ws.cell(row=i, column=1).value = something but when I do so I get an error saying that row value must be between 1 and 1048576.

while cell != 'None':
    cell = ws['A' + str(i)].value
    i = i + 1

In this case I want to find the first cell that as no value in it, not the first cell that contains "None"

Any suggestion?

wovano
  • 4,543
  • 5
  • 22
  • 49
  • Could you add a [mre] and the full traceback? – wovano Dec 06 '22 at 15:30
  • Did you check this question and answer? [ValueError: Row numbers must be between 1 and 1048576](https://stackoverflow.com/questions/73917099/valueerror-row-numbers-must-be-between-1-and-1048576) – wovano Dec 06 '22 at 15:31
  • You seem to have already got an answer in your [previously deleted question](https://stackoverflow.com/questions/74697619/how-to-select-excel-cell-with-variable-in-openpyxl). Empty cells have `None` in them. Not the string `"None"` – Tomerikoo Dec 06 '22 at 15:34
  • @wovano yes did – Eduardo Duarte Dec 07 '22 at 00:06
  • This is NOT a [mre]. If I copy-paste and run this code and run it, I get `NameError: name 'cell' is not defined`. Also, there is no Traceback in the question. – wovano Dec 07 '22 at 06:08

0 Answers0