RosettaCodeData/Task/CSV-data-manipulation/Raku/csv-data-manipulation-1.raku

11 lines
278 B
Raku
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
my $csvfile = './whatever.csv';
my $fh = open($csvfile, :r);
my @header = $fh.get.split(',');
my @csv = map {[.split(',')]>>.Num}, $fh.lines;
close $fh;
my $out = open($csvfile, :w);
$out.say((@header,'SUM').join(','));
$out.say((@$_, [+] @$_).join(',')) for @csv;
close $out;