Tim Carter

unread,
Apr 24, 2017, 12:45:38 PM4/24/17
to mitappinv...@googlegroups.com
I seem to spend my life working with lists of names and things, eventually ending up in Google Apps Scripts and AI2 apps. As I work mainly inside a google domain, accessing all the data there can be a bit of a pickly when working outside of the browser.

I didn't realise you could do this, but whilst playing around with google sheet url parameters, I found I could wget a google sheet and download it as a csv. (wget is the command line program for downloading items on Linux). 

wget https://docs.google.com/spreadsheets/d/<FILE_ID>/export?format=csv -O FirstNames.csv

So wondered if I could do the same with AppInventor. Yes I can!

If you are security conscious about your data then this might not be a solution for you, as you will need to set the sharing option for the google sheet to "Anyone with the link". You can find arguments for the pros and cons of this in many places on the interweb.


Setup

  1. Create your google sheet
  2. Ensure you only have one sheet (Google will only download the first sheet as csv)
  3. Add your list data, one row after the other (makes a data table of one column)
  4. Get the ID of your spreadsheet
(If your list data is in a multiple tab spreadsheet, it is easy enough to create another spreadsheet and =importrange() then data you want)

Then probably easiest to download the aia attached to see how this works, but see below the blocks and a screen grab


The important stuff is going on in the Button1.Click event in web1.Url, i simply added a read file and label to display the contents of the file, as proof.


Not experimented, but guessing this can be done with all manner of google apps documents and non native files too.


The real sticking point is the "Anyone with the link" part, but I understand from the interweb a brute force attack on discovering the fileID would take @ 3 times longer than the age of the Earth! fact is if you share data with anyone, it is no longer secure. However I wouldn't use this method for personal information without expressed permission.


Tim  




CSVDownloadFromGoogleDrive.aia

Taifun

unread,
Apr 24, 2017, 1:50:51 PM4/24/17
to MIT App Inventor Forum
thank you Tim...
see also chapter "GET (select all rows)" here https://puravidaapps.com/spreadsheet.php
and: you also can use SQLish commands to select part of the data of the spreadsheet...

Taifun

Tim Carter

unread,
Apr 25, 2017, 12:21:31 PM4/25/17
to MIT App Inventor Forum
Oh yes, there it is :)

TimAI2

unread,
Jan 5, 2018, 4:05:42 PM1/5/18
to mitappinv...@googlegroups.com
It is also possible to download any sheet from a google spreadsheet as csv.

You will need to modify the download url to include the gid of the sheet.

A full url would look like this:

https://docs.google.com/spreadsheets/d/<FILE ID>/export?format=csv&id=<FILE ID>&gid=<GID ID>


Reply all
Reply to author
Forward
0 new messages