Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
program CSV_data_manipulation;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
System.IoUtils,
|
||||
System.Types;
|
||||
|
||||
type
|
||||
TStringDynArrayHelper = record helper for TStringDynArray
|
||||
function Sum: Integer;
|
||||
end;
|
||||
|
||||
{ TStringDynArrayHelper }
|
||||
|
||||
function TStringDynArrayHelper.Sum: Integer;
|
||||
var
|
||||
value: string;
|
||||
begin
|
||||
Result := 0;
|
||||
for value in self do
|
||||
Result := Result + StrToIntDef(value, 0);
|
||||
end;
|
||||
|
||||
const
|
||||
FILENAME = './Data.csv';
|
||||
|
||||
var
|
||||
i: integer;
|
||||
Input, Row: TStringDynArray;
|
||||
|
||||
begin
|
||||
Input := TFile.ReadAllLines(FILENAME);
|
||||
for i := 0 to High(Input) do
|
||||
begin
|
||||
if i = 0 then
|
||||
Input[i] := Input[i] + ',SUM'
|
||||
else
|
||||
begin
|
||||
Row := Input[i].Split([',']);
|
||||
Input[i] := Input[i] + ',' + row.Sum.ToString;
|
||||
end;
|
||||
end;
|
||||
TFile.WriteAllLines(FILENAME, Input);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue