delimiter change - drivefile download

87 views
Skip to first unread message

Matt Colwell

unread,
Feb 16, 2023, 10:57:10 AM2/16/23
to GAM for Google Workspace
I need to download a google sheet as a delimited text file.

So far, I've only been successful in getting the file as a CSV.  Is there a way to change the delimiter to a pipe character (or something else)? 

Or... Is there a way to download it as an Excel file?  It looks like there's an option for that, but I'm struggling with the syntax.

Thanks 

Ross Scroggs

unread,
Feb 16, 2023, 11:00:17 AM2/16/23
to google-ap...@googlegroups.com
Matt,

Show the command you're using.

Ross

--
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/2d4ffe63-774e-4072-8893-584499748f2cn%40googlegroups.com.


--

Ross Scroggs

unread,
Feb 16, 2023, 11:13:59 AM2/16/23
to google-ap...@googlegroups.com
Matt,

Try: gam user us...@domain.com get drivefile <FileID> format tsv

This gives you a tab separated file; you can change the tabs to |

Ross
--

Matt Colwell

unread,
Feb 16, 2023, 11:18:31 AM2/16/23
to GAM for Google Workspace
I've been using this:

gam user <USER> get drivefile  <FILEID>  csvsheet id:<SHEETID> targetname <LOCALFILE>


I just got the excel download working with this command:

gam user <USER> get drivefile  <FILEID>  format microsoft targetname <LOCALFILE>.xlsx 


If I grab the file in Excel I'll need to convert it into something I can use in a script, so that would be some extra steps.

Matt Colwell

unread,
Feb 16, 2023, 11:23:35 AM2/16/23
to GAM for Google Workspace
I get this error:
Not Downloaded: Format (tsv) not available

Do I need to specify the sheet ID somehow?

Ross Scroggs

unread,
Feb 16, 2023, 2:57:19 PM2/16/23
to google-ap...@googlegroups.com
Matt,

Get 6.42.03, the command will now work.

Ross



--

Ross Scroggs

unread,
Feb 16, 2023, 3:39:25 PM2/16/23
to google-ap...@googlegroups.com
Matt,

Let's suppose your downloaded file in test.tsv, here's how to convert the tabs to |
Mac

tr '\t' "|" < test.tsv > testvb.tsv


Linux

sed -i 's/\t/|/g' test.tsv

Windows Powershell
(Get-Content test.tsv).Replace("`t", "|")

Ross
--

Matt Colwell

unread,
Feb 17, 2023, 10:31:42 AM2/17/23
to GAM for Google Workspace
Thanks Ross, the 6.42.03 version did the trick.

TSVs are usable as is, but I appreciate the code snippets for sed and powershell

Roger Frutiger

unread,
Apr 5, 2023, 7:00:12 PM4/5/23
to GAM for Google Workspace
Ross,

I am having the same issue with GAM 6.53, when I try to download a sheet as a tsv I get the error: ERROR: Format (tsv) not available, but if I specify csv the file downloads correctly. The particular files I am working with have commas in the data so a simple replace of comma to tab wouldn't work. I think because the csv quotes the values with commas I can probably pipe it through Export-Csv and set the delimiter, but I would prefer to just get the file from Google in the correct format.

Roger Frutiger

unread,
Apr 5, 2023, 7:01:34 PM4/5/23
to GAM for Google Workspace
Oh yeah the command I am using is as follows
gam user <file owner> get drivefile id "<drive file id>" format tsv

Ross Scroggs

unread,
Apr 5, 2023, 7:26:54 PM4/5/23
to google-ap...@googlegroups.com
It's a bug in Standard GAM, it works in Advanced GAM:
$ gam user tests...@rdschool.org get drivefile id 1uK-Ca4obeBiojvhWFfMH12lHz71GTwBmJGbL-KnY2tM format tsv
User: tests...@rdschool.org, Download 1 Drive File
  User: tests...@rdschool.org, Drive File: Activity Test, Downloaded to: /Users/admin/Documents/GamWork/Activity Test.tsv, Type: Google Doc


I'll look at a fix for standard GAM

Ross
----
Ross Scroggs



Reply all
Reply to author
Forward
0 new messages