简体   繁体   中英

How to insert data in the second row of a Gsheet?

I'm inserting data into a Google Spreadsheet with this code:

sheet_instance.insert_rows(my_data)

But it always inserts into the first row, where it has some important formulas. Is it possible to keep the first row of the spreadsheet untouched and insert the data starting at the second row, with gspread library?

You can use values_update

sheet_instance.values_update(
    'Sheet1!A2',
    params={
        'valueInputOption': 'USER_ENTERED'
    },
    body={
        'values': [[1, 2, 3]]
    }
)

append_rows might be a good alternative too (you just need to specify table_range )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM