comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to skip lines when reading in a file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to skip lines when reading in a file [message #74951] Mon, 07 February 2011 12:18
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Mon, 7 Feb 2011 10:10:40 -0800 (PST), Ashley Berg wrote:

> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
> rows). I want only the data from the months of December, January, and
> February in a new array, so the resulting time series will be one
> column by 153 rows. I'm not sure how to grab only those three months
> while ignoring the other 9. Could someone show me the best way to do
> this? Thank you!

What about something like:
array=all rows from file
array=reform(array,12,n_elements(array)/12,/overwrite)
array=array[[0,1,11],*] ; wanted months
array=array[*]

Not tested, simply written into the news reader.

HTH, Heinz
Re: How to skip lines when reading in a file [message #74952 is a reply to message #74951] Mon, 07 February 2011 10:34 Go to previous message
Ashley Berg is currently offline  Ashley Berg
Messages: 14
Registered: February 2011
Junior Member
On Feb 7, 11:23 am, Gray <grayliketheco...@gmail.com> wrote:
> On Feb 7, 1:10 pm, Ashley Berg <ashley.b...@gmail.com> wrote:
>
>> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
>> rows).  I want only the data from the months of December, January, and
>> February in a new array, so the resulting time series will be one
>> column by 153 rows.  I'm not sure how to grab only those three months
>> while ignoring the other 9.  Could someone show me the best way to do
>> this?  Thank you!
>
> Do you have some way of knowing which month corresponds to which
> data?  Like a month array or something?  What are your data types?
> You're going to want to use WHERE().

That's a good idea; since there are no month labels on the data in the
file (just the numbers), I can just create a month array, and where
month[i] is DEC, JAN, or FEB I could have it grab temp[i] from my data
array. That way I'd get a new array with just the temps from those
three months. I'll give that a try.
Re: How to skip lines when reading in a file [message #74953 is a reply to message #74952] Mon, 07 February 2011 10:23 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Feb 7, 1:10 pm, Ashley Berg <ashley.b...@gmail.com> wrote:
> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
> rows).  I want only the data from the months of December, January, and
> February in a new array, so the resulting time series will be one
> column by 153 rows.  I'm not sure how to grab only those three months
> while ignoring the other 9.  Could someone show me the best way to do
> this?  Thank you!

Do you have some way of knowing which month corresponds to which
data? Like a month array or something? What are your data types?
You're going to want to use WHERE().
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to skip lines when reading in a file
Next Topic: Mock-up of the Book

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:38:50 PDT 2025

Total time taken to generate the page: 0.00451 seconds