Rename Column Headings

771 views
Skip to first unread message

TheArchiveMan

unread,
Mar 8, 2011, 8:08:25 AM3/8/11
to Google Apps Manager
We can use GAM to extract the Username, Email fields to a .csv file.
Just wanted to know if there was any way to go into the file and
rename the column headers "Username" and "Email" to something else,
for instance "User" and "Mail"? All we want is the names of the
headers changed but all the data below left unchanged. Does anyone
have any ideas on how to accomplish this? Thanks.

Steve Hall

unread,
Mar 8, 2011, 11:26:38 AM3/8/11
to google-ap...@googlegroups.com
Sure - just use the "sed" unix command with some simple regular expressions. To change a file containing...
Username,Email
bsmith,bsm...@gmail.com
jdoe,john...@yahoo.com
...to a file containing...
User,Mail
bsmith,bsm...@gmail.com
jdoe,john...@yahoo.com
...just do something like this:
type extract.csv | sed "1 s/Username/User/" | sed "1 s/Email/Mail/" > new.csv
FYI, the "1" tells sed to only work on the first line of the file. If you're on Mac or Linux, change "type" to "cat". If necessary, you can change the commands to make other adjustments.

If you're on Mac or Linux, you have sed built in. If you're on Windows (any flavor), I highly recommend the open source "UnxUtils" port of unix commands. Assuming you put the "UnxUtils" folder at the top level of your C drive, make sure you add "C:\UnxUtils\usr\local\wbin" to your 'path' environment variable. Also, keep in mind the infamous quote "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." :-)

Steve

Sandip Shah

unread,
Mar 8, 2011, 1:22:28 PM3/8/11
to Google Apps Manager
TheArchiveMan,

The "appropriate" way to do is how Steve H. has recommended.

If you want the output from GAM to be the way you want, then in the
current GAM, change the following lines:

line 1298:
" user_attributes.append({'Email': 'Email'})"
to
" user_attributes.append({'Email': 'Mail'})"

line 1313:
" user_attributes[0].update(Username='Username')"
to
" user_attributes[0].update(Username='User')"

(note the spaces at the beginning of both the lines, Python is "space"
sensitive).

Note that you'll need to do this change every time GAM is updated, and
the line numbers may change.

Ss

On Mar 8, 8:26 am, Steve Hall <st...@steve-hall.com> wrote:
> Sure - just use the "sed" unix command with some simple regular
> expressions. To change a file containing...
>
>     Username,Email
>     bsmith,bsm...@gmail.com
>     jdoe,john....@yahoo.com
>
> ...to a file containing...
>
>     User,Mail
>     bsmith,bsm...@gmail.com
>     jdoe,john....@yahoo.com
>
> ...just do something like this:
>
>     type extract.csv | sed "1 s/Username/User/" | sed "1 s/Email/Mail/"
>      > new.csv
>
> FYI, the "1" tells sed to only work on the first line of the file. If
> you're on Mac or Linux, change "type" to "cat". If necessary, you can
> change the commands to make other adjustments.
>
> If you're on Mac or Linux, you have sed built in. If you're on Windows
> (any flavor), I highly recommend the open source "UnxUtils
> <http://sourceforge.net/projects/unxutils/>" port of unix commands.

Jeff Meanor

unread,
Mar 9, 2011, 11:02:47 AM3/9/11
to google-ap...@googlegroups.com, Sandip Shah
Thanks for your help.

--
You received this message because you are subscribed to the "Google Apps Manager" group.
To post to this group, send email to
google-ap...@googlegroups.com
To unsubscribe from this group, send email to
google-apps-man...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-apps-manager



--
 

Home of Florida's first LEED Gold Certified School

Under Florida law, e-mail addresses are public records. If you do not want your e-mail address
released in response to a public records request, do not send electronic mail to this entity. 
Instead, contact this office by phone or in writing.

Reply all
Reply to author
Forward
0 new messages