[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: load file, skip comment lines
From: |
Joe Koski |
Subject: |
Re: load file, skip comment lines |
Date: |
Thu, 25 Jan 2007 18:54:43 -0700 |
User-agent: |
Microsoft-Entourage/11.2.5.060620 |
on 1/25/07 5:20 PM, Doug Stewart at address@hidden wrote:
> the_verge wrote:
>> I'm using the load(filename) command to load some USGS data. What I want to
>> know is, how do I make it skip the leading comment lines in the data file?
>> Specifically, the syntax I am using is:
>>
>> x = load(filename);
>> A = x(:,1);
>> B = x(:,2);
>> C = x(:,3);
>>
>> etc. So if the first several lines are comment lines, how can I tell it to
>> ignore those lines before beginning to load data? Is there a better way to
>> do that?
>>
>>
>> Thanks,
>> Vergil
>>
> I usually edit the file first and delete those lines.
> Doug
Doug,
Alternatively, I put a # sign in the first column of the header, then octave
ignores those lines. If there is an identifiable string, it's easy to do a
global substitute of #string for string in the header lines.
Another approach, if the number of lines is always the same, is to read
line-by-line (fgetl,fscanf,etc.) until you're past the header, then read the
rest of the lines. Keep in mind that there is also a C-compatible input
format that allows almost anything, but is really slow compared to the usual
octave reads.
Joe