Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.50 KB | None | 0 0
  1. #collect names of csv files in folder; establish header row trackera and open file for writing
  2. my @csv-files = './'.IO.dir(test => / '.csv' /)>>.basename;
  3. my $header-inserted = 0;
  4. my $wh = open "combined.csv", :a;
  5.  
  6. #iterate through each file, writing the header-row only once and writing the rest of the contents out
  7. for @csv-files -> $file {
  8.   my @contents = $file.IO.lines;
  9.   shift @contents if $header-inserted == 1;
  10.   for @contents -> $line {
  11.     $wh.say($line);
  12.   }
  13.   $header-inserted = 1;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement