[Python] Setting range with gspread

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    So I have been trying to set up a program to replace all instances of a number in column in google Sheets with a string using gspread. I believe the first response of the this post covers most of my problems How to replace all cells that starts with in google sheets using python However I cannot find documentation explaing how to assign a gridRange as mentioned at the very end of the first response. My code executes but it does not change anything

    I was hoping to replace every instance of a number with a string in a column.The code executes but it does not update the google sheet


    import gspread
    import pandas as pd
    gc = gspread.service_account(filename="deep-dispatch-463118-t6-c7b089d2f164.json")
    sh = gc.open('Copy of GCE MCQ')
    worksheet = sh.worksheet('2024')
    body = {
    "requests": [
    {
    "findReplace": {
    "find": "12",
    "searchByRegex": True,
    "range": {"D:D",
    "sheetId": worksheet.id,
    },
    "replacement": "Immunity"
    }
    }
    ]
    }​

    Writing gridRange like so stops any errors but does not update the sheet

    Continue reading...

Compartilhe esta Página