1

I have a similar data as below in google sheet. I want to update the pageId for pagename "abc".

PageName page id
xyz         24324354_a
abc         12345678_b
lmn         98765432_c

I'm able to update manually passing B3 sheet.update('B3','updated_value') but How should I get B3 by adding a if condition where pagename=abc in python code.

Need help.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • ```records_data = sheet_instance.get_all_records() test = sheet_instance.col_values(1) rownum = test.index('abc') + 1 print(rownum) row = sheet_instance.row_values(rownum) print(row)``` I'm able to get the row number but I need cell number like B3 to be passed – Nivethitha Thiyagarajan Feb 08 '22 at 06:16

1 Answers1

2

If your provided script in your comment is used, how about the following modification?

Modified script:

# Your provided script in your comment.
records_data = sheet_instance.get_all_records()
test = sheet_instance.col_values(1)
rownum = test.index('abc') + 1
print(rownum)
row = sheet_instance.row_values(rownum)
print(row)

sheet_instance.update_cell(rownum, 2, 'Updated') # Added
  • In this case, rownum can be directly used.

Reference:

Tanaike
  • 181,128
  • 11
  • 97
  • 165