Skip to content

Instantly share code, notes, and snippets.

@jayjanssen
Created September 18, 2013 13:41
Show Gist options
  • Save jayjanssen/6609301 to your computer and use it in GitHub Desktop.
Save jayjanssen/6609301 to your computer and use it in GitHub Desktop.
Parse CSV download from BambooHR to make it useful to import into OSX Contacts
#!/usr/bin/perl
use Text::CSV;
use Data::Dumper;
my $headers = <STDIN>;
my $csv = new Text::CSV;
print "Last, First, Mobile, \"Phone (work)\", \"Email (work)\", \"Skype (work)\"\n";
while( my $line = <STDIN> ) {
$csv->parse( $line );
my @row = $csv->fields();
#print Dumper( \@row );
my @output;
my @names = split( ',', shift @row );
$names[1] =~ s/^\s+//;
push( @output, $names[0] );
push( @output, $names[1] );
push( @output, shift @row );
my $office = shift @row;
my $ext = shift @row;
if( $office eq '' ) {
push( @output, '' );
} else {
push( @output, "$office x$ext" );
}
foreach my $field( @row ) {
push( @output, $field );
}
$csv->combine( @output );
print $csv->string() . "\n";
}
@simeneriks1
Copy link

How does this work- how to use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment