gspread

In python, is it possible to edit a publicy shared google sheet, without an auth code?

拜拜、爱过 提交于 2020-03-03 08:49:06
问题 I have a google sheet which I set so that anyone can edit. I noticed that in the gspread package, you can get a spreadsheet from the link alone. Example: sht1 = gc.open_by_key('1wj9L7Hn779GKP0s4MblkU1wHcqaVcG_E2YKAo1vdof0') Since anyone can edit, providing an auth code for access is not necessary. However, it seems that you always need to initialize it using an auth code. Is there a way to edit a google sheet without any auth code? This may get confused as a duplicate of this post Using

Google Service Account Not able to edit / update a Google Sheet using gspread

大兔子大兔子 提交于 2020-01-25 08:26:24
问题 This is a follow up to this StackOverFlow question. In python, is it possible to edit a publicy shared google sheet, without an auth code? Which advices to use a g-suite service account to access google sheets. import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://www.googleapis.com/auth/spreadsheets'] credentials = ServiceAccountCredentials.from_json_keyfile_name('### downloaded JSON file ###', scope) gc = gspread.authorize(credentials) sht1 = gc

Gspread & Oauth2 on Python 3.4 - Oauth does not support indexing

落花浮王杯 提交于 2020-01-06 02:45:28
问题 I want to use gspread and since client authentication is outdated, I'm trying with Oauth2. I'm new to both gspread & Oauth2. Piecing together from this basic Oauth2 example and the gspread documentation I have the most basic login function. import gspread from oauth2client.client import OAuth2WebServerFlow CLIENT_ID = 'my id' CLIENT_SECRET = 'my secret key' flow = OAuth2WebServerFlow(client_id= CLIENT_ID, client_secret= CLIENT_SECRET, scope='https://docs.google.com/spreadsheets/', redirect

GSpread Cell Merging

北城余情 提交于 2020-01-04 07:54:48
问题 I am trying to merge cells in Gsheets using Gspread for Python, however I can't find any documentation. I have used the gspread_formatting module to format the text and colour of the cell, but I can't find anything to do with merging of the cells. I haven't wrote any code because I can't find any examples. I want to be able to merge the cells based on a range. Can anyone please help me? Cheers. 回答1: You want to know how to merge cells of Google Spreadsheet using gspread. You have already been

Upload CSV to Google Sheets using gspread

半城伤御伤魂 提交于 2020-01-04 02:35:50
问题 I have a Json object which needed to be uploaded to the Google Spreadsheet. I have searched and read various resources but could not find the solution. Is there a way to upload object or csv from locally to google spreadsheet using gspread. I will prefer not to use google client api. Thanks 回答1: You can import CSV data using gspread.Client.import_csv method. Here's a quick example from the docs: import gspread # Check how to get `credentials`: # https://github.com/burnash/gspread gc = gspread

Include gspread module using py2exe, pyinstaller

≡放荡痞女 提交于 2019-12-25 09:59:12
问题 I have created a python application which fetches data from a google spreadsheet and performs the required operation and outputs files with the data accordingly. The application works fine through my ide and the console. I'm using gspread and Tkinter for accessing the google sheets and for the GUI respectively. However when I try to create it into an exe. I keep running into errors. First I tried using py2exe but I keep getting the error ImportError: No module named gspread My setup.py is

python gspread library only writes to worksheet labeled 'sheet1'

泄露秘密 提交于 2019-12-24 15:59:03
问题 My sheet is named 'doc_name', and it has two worksheets, 'sheet1' and 'sheet2'. but, i can only write data to the worksheet labeled 'sheet1'? is this a limitation or am i doing something wrong? this works, wks = gc.open("doc_name").sheet1 but this fails, wks = gc.open("doc_name").sheet2 giving this error, AttributeError: 'Spreadsheet' object has no attribute 'sheet2' i also notice that this fails, wks = gc.open("doc_name"). S heet1 ...where i use a capital 'S'.. and it will only write if i

How would one convert/wrap a HTTPLib2 instance as a Session?

守給你的承諾、 提交于 2019-12-23 04:51:43
问题 I know the title is a big wonky and I apologize for that. The dilemma I have is that gspread uses Session and the Google APIs client library for Python uses HTTPLib2. I have a service account that I have working with the Google API client and want to take the authenticated httplib2.Http() instance and wrap it so that gspread can use it like a Session object. UPDATE: Fixed with update 103 to gspread. Based on Jay Lee's awesome answer below, here's how to initialize the gspread Client with a

python gspread google spreadsheet keeping connection alive

梦想的初衷 提交于 2019-12-22 06:47:54
问题 I'm updating my spreadsheets using gspread , the process takes about an hour, i have about 200 spreadsheets. It seems about 30 minutes into the updating the sheets, the connection drops. Is there a way to keep the login alive? I thought I was keeping the connection alive because I'm opening and writing to different sheets about every 30 seconds. I can use a try statement and if it bombs re-login. I was wondering if anybody had a better way? I'm used to using the simple example from gspread

gspread w/ OAuth2Client Service Account Key

和自甴很熟 提交于 2019-12-18 09:47:18
问题 I am using gspread and a Service Account Key, Other, json file. to continually update a google spreadsheet with python 2.7. I have this running off a Raspberry Pi running the latest Raspian Jessie. my oauth and gspread should all be the latest versions available for my platform. My script runs for one hour(the max token life span),then stops working with the error message : "Invalid token: Statless token expired error" My code is as follows import gspread from oauth2client.service_account