From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: is there Ada package similar to Matlab textscan?
Date: Fri, 17 Jul 2015 13:05:24 +0200
Date: 2015-07-17T13:05:24+02:00 [thread overview]
Message-ID: <moancj$l0o$1@dont-email.me> (raw)
In-Reply-To: <mo9u61$4da$1@speranza.aioe.org>
On 2015-07-17 05:52, Nasser M. Abbasi wrote:
> one parse each field one by one themselves after
> reading the file line by line?
Gnat.Awk is line based but parsing is simple:
with GNAT; use GNAT;
with GNAT.AWK;
with Text_io;
procedure Test is
Computer_File : AWK.Session_Type;
begin
AWK.Set_Current (Computer_File);
AWK.Open (Separators => ",",
Filename => "path/to/file.dat");
while not AWK.End_Of_File loop
AWK.Get_Line;
if AWK.Field(4) = "GB" and then
AWK.Field (18) = "PE" then
Text_io.Put_Line(AWK.Field (5) & " | " &
AWK.Field (8) & " | " &
AWK.Field (2) & " | " &
AWK.Field (11));
end if;
end loop;
AWK.Close (Computer_File);
see
<https://www2.adacore.com/gap-static/GNAT_Book/html/rts/g-awk__ads.htm>
for more examples
--
--
Björn
prev parent reply other threads:[~2015-07-17 11:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 3:52 is there Ada package similar to Matlab textscan? Nasser M. Abbasi
2015-07-17 4:25 ` tmoran
2015-07-17 6:31 ` Dmitry A. Kazakov
2015-07-17 11:05 ` Björn Lundin [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox