###############################
#https://github.com/burnash/gspread
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("Twilio Asset #").sheet1
list_of_lists = wks.get_all_values()
#print(list_of_lists) // print all values
values_list = wks.col_values(2) # print second coluimm
print(values_list)
#################################
Second code
#pip install gspread
#pip install --upgrade oauth2client
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open("Twilio Asset #").sheet1
pp = pprint.PrettyPrinter()
result = sheet.col_values(2)
pp.pprint(result)
###########################################
****Json authentication file**
"type": "service_account",
"project_id": "PPROJECT111",
"private_key_id": "9ffcce7810b1ec988046",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBiG9w0BAQEFAASC5hwVdsVn7QX\nmZuaWMmbfA+Z3wfmOzSuxsSHE464kAGjMyQaC2hrB3HRt6u1/lX3DQ$
"client_email": "twilio@twilio-199919.iam.gserviceaccount.com",
"client_id": "101085707121442275249",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/twilio%40twilio-199919.iam.gserviceaccount.com"
}
https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html
https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html
No hay comentarios:
Publicar un comentario