Answer the question
In order to leave comments, you need to log in
How to write a condition with recursion to find free cells in a table?
There is a table (Google sheets) in which I enter data on expenses
. In column "A" the date is indicated (dateNow.strftime ('%d-%m-%Y')), in columns with "B" and then - the amount (int ).
Algorithm:
1) The first value is inserted into cell B1 value, the date is entered into cell A1.
2) The second value in cell C1, if determines that cell A1 is not empty and enters the value of the amount in C2, the date in A2
The problem is this:
3) The third value in cell D1, If looks again at A1, sees that it is busy and puts date in A2.
How to force to search for free cells in column A?
# Ячейка А1 = пустая?
if bool(wks.cell(row, 1).value) == True:
#прибавляем 1 к значению строки
row = row + 1
#обновляем адрес ячейки
cell = col + str(row)
#вносим дату в А2 и данные в соседние столбцы
wks.update_cell(row, 1, dateWrite)
wks.update_acell(cell, messageCost)
#вставляем дату в А1 и данные в соседние столбцы
else:
wks.update_cell(row, 1, dateWrite)
wks.update_acell(cell, messageCost)
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