help-octave
[Top][All Lists]
Advanced

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

Re: load file, skip comment lines


From: etienne
Subject: Re: load file, skip comment lines
Date: Thu, 25 Jan 2007 21:50:26 -0800 (PST)
User-agent: SquirrelMail/1.4.4

  Hi All,

if you know your_file.txt has exactly, 4 header lines, sthing like this
should do

  system ("perl -ne 'print unless $. <= 4' <  your_file.txt > tmp.txt")
  x = load tmp.txt
  unlink ("tmp.txt")

To delete all lines starting by '#', use

  system ("perl -ne 'print unless /^#/' <  your_file.txt > tmp.txt")

Etc... (more perl single-liners on demand)

  Hth,

  Etienne

On Thu, January 25, 2007 5:59 pm, the_verge said:
>
> Doug,
>
> Thanks for the reply.  Here's a question though, what if you had hundreds
> of
> these files to run, and couldn't be bothered to edit each one?  What's the
> best way to read in a data file with comments at the top?
>
> Thanks,
>
> Vergil
>
>
>
> Doug Stewart 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
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/load-file%2C-skip-comment-lines-tf3119863.html#a8644992
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


-- 
http://www.isr.ist.utl.pt/~etienne



reply via email to

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