GAM Python Library -> Download Google Sheet to Pandas Dataframe

151 views
Skip to first unread message

Eric Dannewitz

unread,
Feb 9, 2022, 3:31:49 PM2/9/22
to GAM for Google Workspace
Starting to play with the python library version of GAMADV

So, if I wanted to pull down a sheet from Google, I can do this

gam.CallGAMCommand(['gam','user', 'j...@auhsdschools.org','get','drivefile','id','1PloHt26W3f8eKdSjR2V8P5BR3xGkNkWQOVAzQMAS4gI','format','csv'])

and it downloads to a file. Cool. But what if I want to put it into say a Pandas dataframe? How would one do that?

Bri Hatch

unread,
Feb 9, 2022, 3:53:03 PM2/9/22
to google-ap...@googlegroups.com
Are you asking the GAM folks how to write python code to import a csv?

Seems out of scope.

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/5c892c28-dbf7-440b-b731-d0e61de2dc0fn%40googlegroups.com.


--
Bri Hatch

"Quite mad, they say. It is good that Zathras does not mind. He's even grown
 to like it. Oh yes."

Eric Dannewitz

unread,
Feb 10, 2022, 11:17:38 AM2/10/22
to GAM for Google Workspace
No. That is not what I was asking. I was asking if GAM's output while being called from Python was something I could put into a dataframe. Seems in the case of pulling down a Google Sheet, it is not.

Sergio Alvarez

unread,
Feb 10, 2022, 3:43:31 PM2/10/22
to GAM for Google Workspace
Hi Eric, 

It would have to be from a different perspective. You use GAM to get access to the information but GAM does not process data, what you would do is to use Python to process the downloaded data, read it and process it how you want it. You can take this as an example:


teamDriveNames = {}

inputFile = open(sys.argv[2], 'r', encoding='utf-8')
for row in csv.DictReader(inputFile, quotechar=QUOTE_CHAR):
teamDriveNames[row['id']] = row['name']
inputFile.close()

This is taken out of the python script for processing a file to create a CSV of permissions, you can see it here:


Regards 

Reply all
Reply to author
Forward
0 new messages