A succesful attempt to read a Google Spreadsheet using Python. It’s also possible to write data, run scripts and custom functions written using Apps Script / Google Cloud etc. It should be relatively easy to send mails, manipulate Google Drive files etc. The Python code is pretty straightfoward and safe.
My goal was to build a safe access to the cloud, without 3rd parties (Bookworm plugin). Sharing for everyone to use and improve. I don’t have much programming skills, so this was not properly debugged and tested yet.
Follow these instructions to get your own client_secret.json and setup the environment.
Rename the file to “credentials.json” and reference that file in Grasshopper.
Log in to receive the access token (you will be prompted to do so automatically). The token will be saved to the same directory as credentials.json.
Set a spreadsheet ID (copy from the spreadsheet’s URL) and sheet name.
Just in case that someone is interested in this Google Sheet access workflow. I scripted “Write Cells” component. Sharing this for you to play and improve my code. It’s never been properly debugged and especially “CV” and “CR” inputs don’t accept structured data. I have an idea how to structure this but failed to convert data tree to nested list properly (treehelpers don’t help any more).
Hi Petr, thank you for sharing your work! I went through the walkthrough steps that you linked, and have generated the credentials.json file, and have installed the Google client library with pip, but when I reference my credentials file, I get this error:
Error running script: No module named ‘google’ [7:1]
Do you have any advice where I could start troubleshooting this? I’ve been googling without success so far. Any help is appreciated. Thanks to everyone in this thread!
I figured out the earlier issue - i just pointed grasshopper to the location where the python packages are located by adding this at the beginning of the first python script component:
Hi. In my case, this part was somehow smooth. I installed python to the computer including libraries /pip. Then it still didn’t work in grasshopper. So I googled for some suggestions and used “#r:” reference for library names which I added directly to the top of grasshopper Python script. RhinoCode and Python modules that are in development - #11 by eirannejad