YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
|
|
@ -25,7 +25,7 @@ $_->[ $column_number{C4} ] += $_->[ $column_number{C1} ] for @rows;
|
|||
push @header, 'Sum';
|
||||
$column_number{Sum} = $#header;
|
||||
|
||||
push $_, sum(@$_) for @rows;
|
||||
push @$_, sum(@$_) for @rows;
|
||||
push @rows, [
|
||||
map {
|
||||
my $col = $_;
|
||||
|
|
|
|||
34
Task/CSV-data-manipulation/Ring/csv-data-manipulation.ring
Normal file
34
Task/CSV-data-manipulation/Ring/csv-data-manipulation.ring
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Project : CSV data manipulation
|
||||
|
||||
load "stdlib.ring"
|
||||
fnin = "input.csv"
|
||||
fnout = "output.csv"
|
||||
fpin = fopen(fnin,"r")
|
||||
fpout = fopen(fnout,"r")
|
||||
csv = read(fnin)
|
||||
nr = 0
|
||||
csvstr = ""
|
||||
|
||||
while not feof(fpin)
|
||||
sum = 0
|
||||
nr = nr + 1
|
||||
line = readline(fpin)
|
||||
if nr = 1
|
||||
line = substr(line,nl,"")
|
||||
line = line + ",SUM"
|
||||
csvstr = csvstr + line + windowsnl()
|
||||
else
|
||||
csvarr = split(line,",")
|
||||
for n = 1 to len(csvarr)
|
||||
sum = sum + csvarr[n]
|
||||
next
|
||||
line = substr(line,nl,"")
|
||||
line = line + "," + string(sum)
|
||||
csvstr = csvstr + line + windowsnl()
|
||||
ok
|
||||
end
|
||||
write(fnout,csvstr)
|
||||
csvend = read(fnout)
|
||||
fclose(fpin)
|
||||
fclose(fpout)
|
||||
see csvend + nl
|
||||
Loading…
Add table
Add a link
Reference in a new issue