Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

update value in google sheet with if condition in another column using python

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Need help.

>Solution :

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:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading