help-octave
[Top][All Lists]
Advanced

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

Re: openning ascii file with headers that don't have special characters


From: Juan Pablo Carbajal
Subject: Re: openning ascii file with headers that don't have special characters (#) in front of them
Date: Tue, 4 Sep 2012 20:54:20 +0200

On Tue, Sep 4, 2012 at 8:19 PM, kevinl <address@hidden> wrote:
> Hi,
>
> I am trying to load an ascii file that look like :
>
> # Some text
> 12   0.0E+00
>  20  35 -131.658 -121.667   57.333   65.825 0.5000 0.2500
>
>    time(years)=           0.0
>    775.545
>    761.773
>    480.000
>    247.591
>   1295.091
>    401.318
>
> I would like to open that file startting at line 5.
> I don't know if load can be used with a specific starting line.
> I tried dlmread :
> dlmread('hypsN10.dir/hbhypsNHYPSGRID10.dat',' ',5,3);
> but it doesn't work as some data start after 3 spaces and other after 2
> spaces.
>
> Thanks
>
>
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/openning-ascii-file-with-headers-that-don-t-have-special-characters-in-front-of-them-tp4643702.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

There is the function textread that would skip any headerlines you
want. However it is very slow, if you plan to read big files, either
load them once with textread and save the data in octave format (or
matlab), after that load is quite fast.

Other solution is that you open the file with "fopen", then read the
number of lines you want to skip using "fgetl" dropping the read outs
and then read the rest of the file with "fscanf" or "fgetl" (this is
basically what textread does).


-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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