Edit a google spreadsheet using javascript/client side code - javascript

I am new to google spreadsheets.
I am trying to use them for a small website where instead of maintaining a DB, I am storing and fetching data from sheets using APIs.
I found this library - https://github.com/mikeymckay/google-spreadsheet-javascript , for fetching data from a published sheet.
It serves my purpose of doing everything in the browser.
But I am not able to figure out how can I write data to same/different spreadsheet.
Do I use Sheet APIs? Can I also do it using App Script ? Is there a ready to use library for the same ?
Can someone please help?

You'd likely want to check out the Google Drive API, rather than Google Apps Scripts. I don't have much experience with it, especially in regards to using it on a website, but that's the best direction to head in.

Related

Using python to connect or write a google apps script to a google sheet

Is it true that it is not possible to directly connect a Google Apps Script (which uses JavaScript) to a Google Sheets spreadsheet using Python?
I am asking this more as a design question: would it not be possible to keep a Google Apps Script in a file and simply use Python to connect it to a gsheets spreadsheet using the spreadsheet id? I have not found a way to do this, but it would be interesting to hear if anyone has found a way to do it and if so how.
I am not sure if this answer is on topic, but I think it might be what you trying to do... That is, push an apps script file up to Google...
I believe you can accomplish this task via the Apps Script Python API:
https://developers.google.com/apps-script/api/quickstart/python
My company does not give the the creds to use the API, so, I can't give you the step by step on this one...
hth,
David
To be fair, I really don't think this is the right approach. Might depend on what you're doing... If you have a Python script that is writing Google Apps Script and needs to push it to Google, you might look in these docs
https://developers.google.com/apps-script/api/reference/rest
If that's not what you're doing and you're trying to manipulate a Spreadsheet by using Python to run some Google Apps Script, refer to the same link. There is "REST Resource: v1.scripts" which has a "run" method.
Last, if your end goal is to manipulate some Google Sheet--you can probably get away with using a Python library like described in this link
https://developers.google.com/sheets/api/quickstart/python
Because just about anything you can use Google Apps Script for, you can technically also do in Python. Except, with Python you have Python and the entire compendium of Python libraries at your disposal. The Google Sheet is ultimately just a data store and reading and writing to it are the things you're trying to do with it--be it Google Apps Script or Python as the driver.
Otherwise, you might be able to use Python to manipulate CLASP
https://github.com/google/clasp

Read Google App Script Files from another script

I am looking to create a little Google App Script to parse another GAS file to pull out the functions and any jsdoc type comments, and then display it.
Like if you navigate to a script you can get the revision history etc, but I wanted to be able to pass in a Drive folder containing multiple script files and develop a front end to display each's content.
I know about the Google Drive REST API with exportLinks do download as JSON.
I wondered if there was a simpler way to do it from another GAS file, or would I need to URLFetch of some description to do it over the RestAPI?
I have tried searching for similar things but they always lead back to the DriveAPI.
Any help with a starting place, or what GAS Objects I should start looking at?
Thank you
You have to use the REST based Drive API, there is really no other alternative. However, you don't need to use URLFetch to access it. Google Apps Script has what's known as Advance Google Services a collection of interfaces that grant native access to many REST based APIS including the Drive API.
You can check out the Drive specific documentation here. Its somewhat sparse, so you'll often have to fall back on the REST based documentation as well as rely on autocomplete inside the script editor to make sense of things.

JavaScript to take data from Google Sheets and populate a Google Site template website page

I was hoping someone could help me write a code or point me to where I could find something to help me do this:
Take Google Sheet data and populate a Google Site template page with it.
This would save me a lot of time because I have all these pages that I want to populate this data with and I have created the template for the look of the page itself. However, I have no idea how to do this. I was thinking about trying to use an add-on to put the data into a template Google doc (I think I found something like that) and then put the Google doc on the webpage, but I would much prefer it right on the web page.
I know this is a lot and I would appreciate any help. If you know of a code that would do this for me (and somewhere that would best help me understand it) as well as any add-ons they have in Google Sheets or Google Sites that may do this (I have not been able to find one), please let me know. Thank you so much!

App script to insert Google Form data into Cloud SQL table (Google Developer's Console)

I am very new to Java and scripts in general, but I am trying to create an app that takes the data from a sites.google website form and places the data into a table within Cloud SQL.
I have successfully created 3 tables (linked with foreign keys) in a database within a Cloud SQL instance on Google's developer console.
The entries in the form correspond to the different headers in the database table, so the data should drop into the appropriate column.
I have tried many of the quickstart and other tutorials within the developer's console documentation links and on the web, but none of them really help me with what I am trying to accomplish..
I have been playing around with code in scripts.google, but haven't really gotten anywhere. Because I am unfamiliar with scripts, I don't know whether I should be using JavaScripts, PHP, python. I've seen tutorials using eclipse and maven but have not been successful/found them helpful.
Hoping someone can steer me in the right direction..
Any feedback or examples I can refer to would be greatly appreciated!

How to consume GTFS feed in Google Map v3 using Javascript?

I'm first time trying to use GTFS(General Transit Feed Specification) with Google Maps as per the Google developers page i have understood the concept of .txt files which are used as feed and for making a demo i downloaded a transit zip files from Google developers page. but I'm not getting how to use those transit files to show information on map. I tried to search tutorial for the same but could not find anything useful. Do i need to parse all those files to show in map or there is something different implementation.
I'm confused.
Please bear me with my lack of knowledge regarding GTFS.
If you want to display stops and routes on a map, you can use gtfs-to-geojson to convert GTFS to GeoJSON that can be loaded onto a Google Map or Mapbox.
Install gtfs-to-geojson:
npm install gtfs-to-geojson -g
Setup a config.json file, then run:
gtfs-to-geojson --configPath /path/to/your/config.json
The tool will output a folder of GeoJSON files.
As far as I know, GTFS is not yet "plug and play" ready - there's no simple way to just load up a GTFS dataset and work with it or query it on Google Maps, using either Google's web interface or their Javascript libraries.
Getting this working requires:
Setting up a (SQL) database and importing the GTFS dataset into that database.
Setting up a query system to get the information you want out of the SQL database (e.g., a web front-end that queries the database backend).
Feel free to look at some examples from around the web:
Broader GTFS discussion, and a link to a PostgreSQL + R solution from James Wong
MongoDB + node.js from Brendan Nee

Categories