comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: is there Ada package similar to Matlab textscan?
Date: Thu, 16 Jul 2015 22:52:33 -0500
Date: 2015-07-16T22:52:33-05:00	[thread overview]
Message-ID: <mo9u61$4da$1@speranza.aioe.org> (raw)

Matlab textscan() build-in function is very useful, I use it
all the time to read textual data from text files.

One bascially tells it the format of each field, and will load
all the data to Matlab data structure (called cells). Then
one can simply loop over the data and process it. The
format used is that of printf() standard format.

It is described here

http://www.mathworks.com/help/matlab/ref/textscan.html

One can also tell it how many lines to skip before
starting to read (this is in order to  bypass any
file headers) and tell it what is the field delimiter
between the columns of the data.

For example, given this text file

----- foo.txt---------------------
Student_ID  | Test1  | Test2  | Test3
    1,           91.5,     89.2,     77.3
    2,           88.0,     67.8,     91.0
    3,           76.3,     78.1,     92.5
--------------------------------

It is read as

C = textscan(fileID,'%d %f %f %f','HeaderLines',1,'Delimiter',',')

That is all. Now C will contain all the data in, in
what is called cell columns. C{1}, C{2}, C{3}, C{4}.

Is there a similar way to read data using Ada or must
one parse each field one by one themselves after
reading the file line by line?  I searched for an
Ada package that does something similar to textscan, but
so far did not find one.

thanks,
--Nasser






             reply	other threads:[~2015-07-17  3:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  3:52 Nasser M. Abbasi [this message]
2015-07-17  4:25 ` is there Ada package similar to Matlab textscan? tmoran
2015-07-17  6:31 ` Dmitry A. Kazakov
2015-07-17 11:05 ` Björn Lundin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox