So far I've managed to make a python script using PyDrive to a new Google Sheet, using:
myfile = drive.CreateFile({
"id": "IDHERE"
})
myfile.SetContentFile('FILENAME.csv')
myfile.Upload()
However, ideally I'd like to be able to specify not only the spreadsheet ID to upload to, but the GID of the specific sheet in the spreadsheet to add the information to.
Does anyone know if this is possible?
Related
The task is to save the stored credential file contents to database.
I am using the Google Java client quickstart project to get calendar and events from google. I am also using the offline access flag and set it as true. In the startup code it uses this:
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
So instead of this FileDataStoreFactory can we use something else, so that I can write the contents to my database
Full code : https://developers.google.com/calendar/quickstart/java#step_3_set_up_the_sample
I wanted to understand if I can save this StoredCredential file contents to the database for each user, so that I can schedule this calendar sync.
Any help will be appreciated.
I would like to call my private google spreadsheet by bash/shell. I don't want to edit it or something, only read it and put the content on the stand-output...
Is it possible?
I found a way, where I can call published projects from Google Drive, but that doesn't fit, as I have confidential data in that spreadsheet!
Also I haven't find an easy to use API solution to do that one simple thing.
Thanks!
Yes it's possible.
Your script will need to do 3 things, each with curl:-
Use a saved Refresh Token to request an Access Token
Use the Access Token to fetch your spreadsheet's File resource (json)
Parse the json to extract the exportLinks object, and choose which format (eg. csv) you want to download
GET that exportLink
Google Sheets allows publishing any spreadsheet to web. Doing so exposes the data contained in the published spreadsheet for access via variety of APIs, such as Google Sheets API.
This is all fined and good, except for one thing. Accessing the a published worksheet via API, returns email addresses of the users who have contributed to that worksheet.
For example a request like this:
https://spreadsheets.google.com/feeds/cells/[key]/[sheetId]/public/basic?alt=json
Among other information, will also return this:
"author": [ {
"name": {
"$t": "***"
},
"email": {
"$t": "***#***.com"
}
} ],
The *** in the above snippet are real Google account names and emails.
Is there a way, either via document properties or via generic Google Account properties, to disable publishing of your email address via public APIs?
There is no way to hide that information in that spreadsheet.
However, here is a workarround:
copy the sheet contents to another spreadsheet, and publish that other spreadsheet. Copying can be done several ways:
You can make a manual copy, which will preserve everything including images, but is harder to maintain in sync.
use the =ImportRange formula to import values automatically into the copy. that handles changes but doesnt handle all formatting and wont work if images change (unless they are placed using =image formula).
=IMPORTRANGE("1z5afM6Wn-8RKsdUpTPicU0d81YCWX4bqzgKIna1uep0","Instructions!A1:E") for example will copy all content in columns A to E into your sheet.
In the published sheet make that "File:Spreadsheet settings" is set to "Recalculation: on change and every minute".
A more detailed example of using importRange is in this blogpost I made, see the part about importRange to copy the "instructions" sheet to other sheets: http://zigmandel.blogspot.com/2015/09/how-i-crowd-translated-my-product-tour.html
3. have an apps script with a trigger to copy the entire sheets into the published spreadsheet. that will preserve everything but is a little more code to delete the old sheets and copy the new ones over.
And of course, the email you use for making those copies (manually or by script) needs be one you don't mind publishing.
This is a google spreadsheet script question.
I have a GUI setup in order to search for "SouthWest" and then find a "test" sheet. This is the code I am using.
var file = DocsList.getFolder("SouthWest").find("test");
This works just fine when I run it under my account (as I have this folder and file setup correctly) but when another user is logged into google docs it will attempt to search for this folder/file under the new user instead of the owner of the document. Is there a way to have it just search the DocsList of the owner of the spreadsheet that is currently open? The error that I get under the new user is "Error encountered: Cannot find folder SouthWest." Thanks.
If you always want to access the same file, you can use the getFileById method and address it directly instead of searching every time:
https://developers.google.com/apps-script/class_docslist#getFileById
Of course, you should make sure that all users are allowed to access that file.
I am doing a project in grails using groovy to upload an image. I have been able to fetch a file from my-computer and store it in a location and display it from there. I wish to accept a url from the user during run time and store the image in the locaion and display from there. Help please
Please consider Gregg's comment, but if you stay with your idea, this is the way I would do it:
new File("path/to/local/image.jpg").bytes = new java.net.Url("http://url.from.user/image.jpg").bytes