Created
November 8, 2015 19:55
-
-
Save autarch/da744699061efabb0dcc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use v6; | |
| use Text::CSV; | |
| sub MAIN ( IO() :$in, IO() :$out ) { | |
| my $csv_in = Text::CSV.new; | |
| my $csv_out = Text::CSV.new( :eol("\r\n") ); | |
| my $in_fh = $in.open(:r); | |
| my $out_fh = $out.open(:w); | |
| $csv_out.print( $out_fh, < person_id event > ); | |
| my $position; | |
| while my @fields = $csv_in.getline($in_fh) { | |
| next unless @fields.any; | |
| if @fields[0] ~~ m/^ <[ A .. Z \c[SPACE] ]>+ $/ { | |
| $position = @fields[0].split(q{ }).map({ m/^ CAA || PPV $/ ?? .uc !! .tclc }).join(q{ }); | |
| next; | |
| } | |
| next unless @fields[*-1] ~~ m/<[ y x ]>/; | |
| die 'No position defined yet' | |
| unless defined $position; | |
| my $event = 'Twin Cities Veg Fest 2015 '; | |
| $event ~= $position; | |
| $event ~= q{ } ~ @fields[0] if @fields[0]; | |
| $csv_out.print( $out_fh, @fields[*-2], $event ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment