简体   繁体   中英

how to get data from google spread sheet on python using link

I want to read data in google spreadsheet using python.

I have a spreadsheet link.

I don't want to using oauth2client. Because only read what I want to. not write.

Is there a way I can do?

  1. you can't do it without using oauth.
  2. there's a good library called gspread - check it out.
  3. Running oauth is as simple as the following code example (you should, first, create a google developer account and get your private key etc
  4. See the following code example (that uses gspread)

from oauth2client.client import SignedJwtAssertionCredentials

def authenticate_and_get_spreadsheet():
    scope = ['https://spreadsheets.google.com/feeds']
    client_email = get_client_email() # something that looks like 962835581947-l1r8s2brhu5sjfljkg7ve54fcfxuio2b@developer.gserviceaccount.com
    private_key = get_private_key()
    credentials = SignedJwtAssertionCredentials(client_email, private_key, scope)
    gc = gspread.authorize(credentials)
    return gc


def get_spreadsheet():
    gc = authenticate_and_get_spreadsheet()
    ss = gc.open_by_key('1FxDkjsdhffQOPC-f93Cccebkjasd5NMzl4AahDk')  # document key
    return ss # now you can read/write this spreadsheet

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