How do I access (read, write) Google Sheets spreadsheets with Python?

前端 未结 8 824
盖世英雄少女心
盖世英雄少女心 2020-11-29 15:41

I am wondering if you can point me to an example of reading/writing to/from a google doc/spreadsheet using python.

I did look at google docs API here https://develo

8条回答
  •  萌比男神i
    2020-11-29 16:13

    Take a look at gspread port for api v4 - pygsheets. It should be very easy to use rather than the google client.

    Sample example

    import pygsheets
    
    gc = pygsheets.authorize()
    
    # Open spreadsheet and then workseet
    sh = gc.open('my new ssheet')
    wks = sh.sheet1
    
    # Update a cell with value (just to let him know values is updated ;) )
    wks.update_cell('A1', "Hey yank this numpy array")
    
    # update the sheet with array
    wks.update_cells('A2', my_nparray.to_list())
    
    # share the sheet with your friend
    sh.share("myFriend@gmail.com")
    

    See the docs here.

    Author here.

提交回复
热议问题