18 lines
485 B
Text
18 lines
485 B
Text
\\ CSV data manipulation
|
|
\\ 10/24/16 aev
|
|
\\ processCsv(fn): Where fn is an input path and file name (but no actual extension).
|
|
processCsv(fn)=
|
|
{my(F, ifn=Str(fn,".csv"), ofn=Str(fn,"r.csv"), cn=",SUM",nf,nc,Vr,svr);
|
|
if(fn=="", return(-1));
|
|
F=readstr(ifn); nf=#F;
|
|
F[1] = Str(F[1],cn);
|
|
for(i=2, nf,
|
|
Vr=stok(F[i],","); if(i==2,nc=#Vr);
|
|
svr=sum(k=1,nc,eval(Vr[k]));
|
|
F[i] = Str(F[i],",",svr);
|
|
);\\fend i
|
|
for(j=1, nf, write(ofn,F[j]))
|
|
}
|
|
|
|
\\ Testing:
|
|
processCsv("c:\\pariData\\test");
|