gspread

How to write a table (list of lists) to Google Spreadsheet using gspread

筅森魡賤 提交于 2019-12-03 19:42:22
I have a table which is presented as Python's list of lists and I'd like to write it down to some Google Spreadsheet using gspread library. However, it seems that gspread does not have such function out of the box. Of course I can use loop and update particular cells but it is very inefficient solution because it have to perform multiple requests (one request per cell). How to do it better? This recent answer to a similar question seems much simpler: my_list = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h']] sh.values_update( 'Sheet1!A1', params={'valueInputOption': 'RAW'}, body={'values': my

Python - Gspread Request Error 401

ⅰ亾dé卋堺 提交于 2019-12-03 09:13:17
I'm currently making a Discord-bot that connects to a Google-spreadsheet (gspread). But after I've been running it for a while it starts to hand out errors and it can't connect to my gspread anymore (unless i restart it). The error that I'm receiving: ( https://hastebin.com/odutucawuv.tex ) Ignoring exception in command sub Traceback (most recent call last): File "C:\Python36\lib\site-packages\discord.py-0.16.10- py3.6.egg\discord\ext\commands\core.py", line 50, in wrapped ret = yield from coro(*args, **kwargs) File "C:\Users\simvid-5\Desktop\Pogomoves\DiscordBot.py", line 65, in sub val =

Gspread - Change Listener?

醉酒当歌 提交于 2019-12-02 06:38:58
问题 I currently run a daemon thread that grabs all cell values, calculates if there's a change, and then writes out dependent cells in a loop, ie: def f(): while not event.is_set(): update() event.wait(15) Thread(target=f).start() This works, but the looped get-all calls are significant I/O. Rather than doing this, it would be much cleaner if the thread was notified of changes by Google Sheets. Is there a way to do this? 回答1: I rephrased my comment on gspread GitHub's Issues: Getting a change

Gspread - Change Listener?

不羁的心 提交于 2019-12-02 06:28:11
I currently run a daemon thread that grabs all cell values, calculates if there's a change, and then writes out dependent cells in a loop, ie: def f(): while not event.is_set(): update() event.wait(15) Thread(target=f).start() This works, but the looped get-all calls are significant I/O. Rather than doing this, it would be much cleaner if the thread was notified of changes by Google Sheets. Is there a way to do this? I rephrased my comment on gspread GitHub's Issues: Getting a change notification from Google Sheets is possible with help of installable triggers in Apps Script. You set up a

Gspread to access google spreadsheet: HttpAccessTokenRefreshError, invalid JWT

谁说胖子不能爱 提交于 2019-12-02 00:13:11
问题 I'm struggling to get access to a google spreadsheet with python 2.7 using gspread. Here's what I have so far: import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds'] credentials = ServiceAccountCredentials.from_json_keyfile_name( 'credentials.json', scope) gc = gspread.authorize(credentials) wks = gc.open("PracticeOpsBS").sheet1 The result is a bunch of stuff that I think is showing me what is going on, resulting in

gspread “SpreadsheetNotFound” on certain workbooks

跟風遠走 提交于 2019-12-01 16:17:46
I have a google drive folder with hundreds of workbooks. I want to cycle through the list and update data. For some reason, gspread can only open certain workbooks but not others. I only recently had this problem. It's not an access issue because everything is in the same folder. I get raise SpreadsheetNotFound when I open_by_key(key) . But then when I take the key and paste it into an URL, the sheet opens. Which means it's not the key. What's going on here? I'm surprised other people are not encountering this error. Have I hit my limit on the number of Google sheets I can have? I have about 2

gspread “SpreadsheetNotFound” on certain workbooks

杀马特。学长 韩版系。学妹 提交于 2019-12-01 15:19:52
问题 I have a google drive folder with hundreds of workbooks. I want to cycle through the list and update data. For some reason, gspread can only open certain workbooks but not others. I only recently had this problem. It's not an access issue because everything is in the same folder. I get raise SpreadsheetNotFound when I open_by_key(key) . But then when I take the key and paste it into an URL, the sheet opens. Which means it's not the key. What's going on here? I'm surprised other people are not

Python/gspread - how can I update multiple cells with DIFFERENT VALUES at once?

岁酱吖の 提交于 2019-11-30 15:34:27
问题 To update a range of cells, you use the following command. ## Select a range cell_list = worksheet.range('A1:A7') for cell in cell_list: cell.value = 'O_o' ## Update in batch worksheet.update_cells(cell_list) For my application, I would like it to update an entire range, but I am trying to set a different value for each individual cell. The problem with this example is that every cell ends up with the same value. Updating each cell individually is inefficient and takes way too long. How can I

gspread w/ OAuth2Client Service Account Key

∥☆過路亽.° 提交于 2019-11-29 18:12:42
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 import ServiceAccountCredentials import httplib2 from httplib2 import Http scope = ['https://spreadsheets

Can I write whole lines in Google Spreadsheets using gspread in python?

纵饮孤独 提交于 2019-11-29 12:13:19
I am trying to write a simple script that will take csv as an input and write it in a single spreadsheet document. Now I have it working however the script is slow. It takes around 10 minutes to write cca 350 lines in two worksheets. Here is the script I have: #!/usr/bin/python import json, sys import gspread from oauth2client.client import SignedJwtAssertionCredentials json_key = json.load(open('client_secrets.json')) scope = ['https://spreadsheets.google.com/feeds'] # change to True to see Debug messages DEBUG = False def updateSheet(csv,sheet): linelen = 0 counter1 = 1 # starting column in