Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,19 +0,0 @@
|
|||
package CSV is
|
||||
|
||||
type Row(<>) is tagged private;
|
||||
|
||||
function Line(S: String; Separator: Character := ',') return Row;
|
||||
function Next(R: in out Row) return Boolean;
|
||||
-- if there is still an item in R, Next advances to it and returns True
|
||||
function Item(R: Row) return String;
|
||||
-- after calling R.Next i times, this returns the i'th item (if any)
|
||||
|
||||
private
|
||||
type Row(Length: Natural) is tagged record
|
||||
Str: String(1 .. Length);
|
||||
Fst: Positive;
|
||||
Lst: Natural;
|
||||
Nxt: Positive;
|
||||
Sep: Character;
|
||||
end record;
|
||||
end CSV;
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package body CSV is
|
||||
|
||||
function Line(S: String; Separator: Character := ',')
|
||||
return Row is
|
||||
(Length => S'Length, Str => S,
|
||||
Fst => S'First, Lst => S'Last, Nxt => S'First, Sep => Separator);
|
||||
|
||||
function Item(R: Row) return String is
|
||||
(R.Str(R.Fst .. R.Lst));
|
||||
|
||||
function Next(R: in out Row) return Boolean is
|
||||
Last: Natural := R.Nxt;
|
||||
begin
|
||||
R.Fst := R.Nxt;
|
||||
while Last <= R.Str'Last and then R.Str(Last) /= R.Sep loop
|
||||
-- find Separator
|
||||
Last := Last + 1;
|
||||
end loop;
|
||||
R.Lst := Last - 1;
|
||||
R.Nxt := Last + 1;
|
||||
return (R.Fst <= R.Str'Last);
|
||||
end Next;
|
||||
|
||||
end CSV;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
with CSV, Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure CSV_Data_Manipulation is
|
||||
Header: String := Get_Line;
|
||||
begin
|
||||
Put_Line(Header & ", SUM");
|
||||
while not End_Of_File loop
|
||||
declare
|
||||
R: CSV.Row := CSV.Line(Get_Line);
|
||||
Sum: Integer := 0;
|
||||
begin
|
||||
while R.Next loop
|
||||
Sum := Sum + Integer'Value(R.Item);
|
||||
Put(R.Item & ",");
|
||||
end loop;
|
||||
Put_Line(Integer'Image(Sum));
|
||||
end;
|
||||
end loop;
|
||||
end CSV_Data_Manipulation;
|
||||
Loading…
Add table
Add a link
Reference in a new issue