I am trying to create a google cloud function that is called when a user clicks a button in google sheets. This function goes through the data and updates another sheet. I have been using pygsheets to do this but I would like to use google cloud functions so that anyone can update the sheet without emailing me to open a terminal and run the script.
My initial error message says that when i run pygsheets.authorize() that this method is trying to write in a read only file system. I have tried to make my own custom credentials but have gotten nowhere with them. I have linked the conversation I had with the maintainer of the pygsheet project.
I am self taught and thus would happily take any advice on how to resolve this issue. I would like to keep using pygsheets if possible as I have not seen any python google sheets tools on par with it. Please help this issue has stumped me for a couple of weeks.
Related
Actually I'm doing a attendance management system which gets the users Id, in time and uploads it to google sheet. Now the catch is inorder to write in google sheet we need internet, I know I can use Microsoft excel instead, But for certain reason I need to use Google sheets (because it includes a google script). Now I need to know whether I can write to google sheets without the internet or not!!
I understand that you want offline access to Sheets using Python. If I understood the situation correctly, you only need to give an eye to this guide about OAuth 2.0 for Desktop Apps, especially the part about calling Google APIs. Please, ask me any doubts about this approach.
Basically I am looking for updating the google sheet from my linux/unix box using shell scripts. Since I couldnt find much with shell scripts , thought of using python to update the google sheet.
Most answers were redirecting to create google project for its api key / OAuth key. I could not create a project in google api / generate a api key as i dont have access to create one at organization level / no organization level. Its asking for location to choose and I dont find any.
Is there any other way to update a google sheet with wget or sudo or CURL or any other method in python ?
You actually don't need an organization to create an API Key, when you click on "New Project" in the Google Cloud Platform you can leave it blank.
https://i.stack.imgur.com/m7C2T.png
Then you have to use the api key in your python code to be able to access your sheets.
I currently am webscraping a website once per day to track changes through time, i wanted to move my project to an Azure cloud so I dont need to keep my PC on during the time of the scrape.
I've been exploring options and decided to use an Azure Function App, specifically an HTML trigger.
I've gotten my python file loaded in Visual Studio Code and linked it to my Azure portal, however I am now stuck on the actual step of running the python file that starts the scrape from the HTML trigger, as well as the process of storing those results in an Azure Table output binding that I have created.
Can anyone point me in the right direction?
Thanks in Advance!
I have an Excel (.xlsx) file in my Office 365 (Sharepoint Online). And I want to use Python to programmatically access (read and write the cells in the worksheets) the Excel file. It seems that Microsoft Graph is the right API to do it.
But I'm confused about how to authenticate with the Microsoft Graph API. It seems to need to register some kind of application in Azure AD and need the approval of my Azure AD admin. And when it gets to run, it uses the OAuth: pop up a window, let the user to login, then click the approve button.
The Python script I'm developing will be only used by myself. So I'd like to avoid OAuth because it is for multiple users. I don't need to support multiple users. And OAuth requires the user's consent in the UI. But what I want is a background authentication without any UI interaction.
So my question is how to authenticate with Microsoft Graph API programmatically in Python with my own Office 365 account (a Email username and a password)? Thank you very much!
Here is a link to the Microsoft Graph API Connect Sample for Python. I recommend following their example, getting it working, then try to change it for your own needs.
At the bottom of the page, they also give information on how to reach them here on StackOverflow.
Hope it helps,
J
I am using gspread to collect data from several hundred Google Sheets spreadsheets. I parse the files stored by Google Drive in a local directory and obtain the URLs for all the spreadsheets within a specified folder. Then I use a python wrapper to go through the URLs and a shell script wrapper to jump start the python wrapper when the connection glitches out.
One of the causes for the glitches is the SpreadsheetNotFound error. I did a quick check about halfway through and found that 21/139 (~15%) of my spreadsheets always get this error (I have it skip the spreadsheet if it's not found five times). I have gone in with iPython and manually tested these with open_by_url, open_by_key, and open (with the title), but they all return the same SpreadsheetNotFound error. The most frustrating part is being able to copy the URL directly from my error message, pasting it in the browser, and the browser going straight to the spreadsheet without a problem. The second most frustrating part is that it works beautifully for ~85% of the spreadsheets, but 85% is not exactly going to cut it.
I'm not even sure this is solvable. I'm just curious if anyone else out there has had this problem with gspread.
Thanks for any feedback.
Edit 1: Hm, the failing spreadsheets were all created prior to 2/2/15. The older sheets have been updated to the newest version of Drive - that may have had an effect on the API.
From the Gspread docs:
ClientLogin is deprecated:
https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015.
Please use oAuth2 authorization instead:
http://gspread.readthedocs.org/en/latest/oauth2.html
So I assume you're using oAuth2. Which means you need to add the email address in that json cert file to the spreadsheet.
Using OAuth2 for Authorization
See point #7:
Go to Google Sheets and share your spreadsheet with an email you have
in your json_key['client_email']. Otherwise you’ll get a
SpreadsheetNotFound exception when trying to open it.