help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading Files with mixed text and numbers


From: Francesco Potortì
Subject: Re: Loading Files with mixed text and numbers
Date: Mon, 10 Jul 2017 14:01:26 +0200

>I did this all the time with Matlab--loaded files with the very common 
>form of records like this:
>2017/07/07,   13:59:59,   022.2,   12.69
>
>I found the matlab "textscan" absurdly complicated for this simple task, 
>generating nested table arrays with lots of associated book keeping of 
>braces, brackets etc. So I finally used matlab "readtable" which worked 
>fine.
>
>When I tried this in Octave it became apparent that the readtable 
>function is not implemented. Using csvread leads me to invalid results 
>(it apparently is for numbers and does not support the date strings).

The function textread (an alternative to textscan) behaves in a way
similar to Matlab's readtable, only thing is that you must provide it
with the type of columns data.  In your case:

[dat,tim,n1,n2] = textread (filename, "%s %s %f %f");

>So - short or writing loops does Octave implement something similar to 
>readtable or some simple way to perform this task--loading comma 
>separated strings into a regular array?

Matlab's readtable loads number-type columns into regular arrays, and
text-type columns into cell arrays of strings, like textread.  Is that
what you want?

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it




reply via email to

[Prev in Thread] Current Thread [Next in Thread]