Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #collect names of csv files in folder; establish header row trackera and open file for writing
- my @csv-files = './'.IO.dir(test => / '.csv' /)>>.basename;
- my $header-inserted = 0;
- my $wh = open "combined.csv", :a;
- #iterate through each file, writing the header-row only once and writing the rest of the contents out
- for @csv-files -> $file {
- my @contents = $file.IO.lines;
- shift @contents if $header-inserted == 1;
- for @contents -> $line {
- $wh.say($line);
- }
- $header-inserted = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement