Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/CSV-data-manipulation/Raku/csv-data-manipulation-1.raku
Normal file
10
Task/CSV-data-manipulation/Raku/csv-data-manipulation-1.raku
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
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;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
use Text::CSV;
|
||||
my $csvfile = './whatever.csv';
|
||||
my @csv = Text::CSV.parse-file($csvfile);
|
||||
# modify(@csv); # do whatever;
|
||||
csv-write-file( @csv, :file($csvfile) );
|
||||
Loading…
Add table
Add a link
Reference in a new issue