Avoid printing CSV header multiple times when printing the output of a gam csv command

103 views
Skip to first unread message

Evgeny Shcherbakov

unread,
Dec 10, 2019, 9:59:06 AM12/10/19
to GAM for G Suite
Whenever I am running any GAM CSV command I end up with the CSV header printed for every single output.

For example if I would like to print the number of contacts in a specific contact group for my users I run:

gam print group-members group my_group_name | gam csv - gam user ~email print contacts selectcontactgroup my_contact_group countsonly

the output will be something along the lines of:

User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts
User,Contacts


As you can see the output includes the CSV Header "User,Contacts" for every single user
My desired output would be:


Is there a setting in GAM I can change? I have checked the wiki but have not found anything regarding this.\

Thank you in advance for any tips suggestions

By the way the gam version I am using is the following:
Ross Scroggs <ross.s...@gmail.com>
Python 3.8.0 64-bit final
google-api-python-client 1.7.8
httplib2 0.13.0
oauth2client 4.1.3
Linux Ubuntu 16.04 Xenial x86_64
Path: /home/egene/bin/gamadv-xtd3



Ross Scroggs

unread,
Dec 10, 2019, 10:40:29 AM12/10/19
to google-ap...@googlegroups.com
Evgeny,


Parallel processing:
gam print group-members group my_group_name | gam redirect csv - multiprocess csv - gam user ~email print contacts selectcontactgroup my_contact_group countsonly
Serial processing:
gam redirect csv - gam group my_group_name print contacts selectcontactgroup my_contact_group countsonly
Send the output to stdout: redirect csv -
Send the output to a file: redirect csv ./file.csv

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" 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/5f615108-b1c9-4c8b-bf00-d12402089cc4%40googlegroups.com.


--

Evgeny Shcherbakov

unread,
Dec 10, 2019, 11:17:33 AM12/10/19
to GAM for G Suite
Thank you very much Ross!
Your proposed solution works great for me.
I will look into the Meta Commands and File Redirection, redirection seems like something that I could use in some of my GAM scripts :)

On Tuesday, December 10, 2019 at 4:40:29 PM UTC+1, Ross Scroggs wrote:
Evgeny,


Parallel processing:
gam print group-members group my_group_name | gam redirect csv - multiprocess csv - gam user ~email print contacts selectcontactgroup my_contact_group countsonly
Serial processing:
gam redirect csv - gam group my_group_name print contacts selectcontactgroup my_contact_group countsonly
Send the output to stdout: redirect csv -
Send the output to a file: redirect csv ./file.csv

Ross

Ross Scroggs <ross....@gmail.com>
Python 3.8.0 64-bit final
google-api-python-client 1.7.8
httplib2 0.13.0
oauth2client 4.1.3
Linux Ubuntu 16.04 Xenial x86_64
Path: /home/egene/bin/gamadv-xtd3

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs
Reply all
Reply to author
Forward
0 new messages