H
H
Headballz2019-07-14 02:07:56
Python
Headballz, 2019-07-14 02:07:56

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

2 answer(s)
H
Headballz, 2019-07-14
@Headballz

Decided to search for a cell by value, followed by a replacement.

D
Dimonchik, 2019-07-14
@dimonchik2013

while it’s bad, that the condition , that the code , “both are worse” is
best to draw or pseudo-graphics, which cells have / should have

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question