regex-matched formatted input, or selecting a few columns in a CSV file?

Muthiah Annamalai muthuspost at gmail.com
Wed Jan 16 02:14:51 CST 2008


novakyu wrote:
> Hi,
>
> I am trying to read from a CSV file, where all the numerical data is
> on the 4th and 5th column (1-3rd columns contain additional
> information about instruments). Is there a way to read it directly
> into Octave using something similar to fscanf? So far, I've been
> re-writing the data files using Perl and then loading it into Octave,
> but it's getting a little tedious to keep doing it that way. Here's a
> sample of the data that I want to read:
>
> Record Length,2.500000e+03,,  -0.046000000000,  -1.44000,
> Sample Interval,2.000000e-04,,  -0.045800000000,  -1.44000,
> Trigger Point,2.300000000000e+02,,  -0.045600000000,  -1.44000,
> ,,,  -0.045400000000,  -1.44000,
> ,,,  -0.045200000000,  -1.44000,
> ,,,  -0.045000000000,  -1.44800,
>
> As you can see, actual X and Y values are on the third and fourth columns.
>
> Thank you,
>
> Andrzej
>   

Octave has support for fscanf(), regexp() and friends, and since you use 
PERL already,
you can write your own specific data loader.
-Muthu



More information about the Help-octave mailing list