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

Home » Public Forums » archive » Reading particular data from a text 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
Reading particular data from a text file [message #91171] Wed, 10 June 2015 09:24 Go to next message
Rosie is currently offline  Rosie
Messages: 27
Registered: September 2012
Junior Member
I have a text file as shown.
First column(S) I have 2 values 1 and 2
2nd column (E) I have 3 values , 1,2,3 as shown repeating.
3rd column (N)shows number of years.
Years (Y)are given from column 4 onward.
I need to pick up years for corresponding S and E. What would be the best possible ways to pick up those years ?

S E N Y
1 1 1 2004
1 2 2 2001,2000
1 3 3 1999,2000,2006
2 1 3 2000,2001,2005
2 2 0
2 3 1 2000

Thanks for any suggestion.
Regards.
Re: Reading particular data from a text file [message #91174 is a reply to message #91171] Thu, 11 June 2015 09:59 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Wednesday, June 10, 2015 at 12:24:37 PM UTC-4, Parij wrote:
> I have a text file as shown.
> First column(S) I have 2 values 1 and 2
> 2nd column (E) I have 3 values , 1,2,3 as shown repeating.
> 3rd column (N)shows number of years.
> Years (Y)are given from column 4 onward.
> I need to pick up years for corresponding S and E. What would be the best possible ways to pick up those years ?
>
> S E N Y
> 1 1 1 2004
> 1 2 2 2001,2000
> 1 3 3 1999,2000,2006
> 2 1 3 2000,2001,2005
> 2 2 0
> 2 3 1 2000
>
> Thanks for any suggestion.
> Regards.

I would first read in the file using something like idlastro's readcol.pro with format="i,i,i,a" so that S, E, and N are integers and Y is a string. Then figure out which rows you want using logic on S and E, and for each row i use something like FIX(STRSPLIT(y[i], ',', /EXTRACT)) to get the list of years associated with it.

-Jeremy.
Re: Reading particular data from a text file [message #91183 is a reply to message #91174] Fri, 12 June 2015 01:34 Go to previous message
Rosie is currently offline  Rosie
Messages: 27
Registered: September 2012
Junior Member
On Thursday, June 11, 2015 at 5:59:19 PM UTC+1, Jeremy Bailin wrote:
> On Wednesday, June 10, 2015 at 12:24:37 PM UTC-4, Parij wrote:
>> I have a text file as shown.
>> First column(S) I have 2 values 1 and 2
>> 2nd column (E) I have 3 values , 1,2,3 as shown repeating.
>> 3rd column (N)shows number of years.
>> Years (Y)are given from column 4 onward.
>> I need to pick up years for corresponding S and E. What would be the best possible ways to pick up those years ?
>>
>> S E N Y
>> 1 1 1 2004
>> 1 2 2 2001,2000
>> 1 3 3 1999,2000,2006
>> 2 1 3 2000,2001,2005
>> 2 2 0
>> 2 3 1 2000
>>
>> Thanks for any suggestion.
>> Regards.
>
> I would first read in the file using something like idlastro's readcol.pro with format="i,i,i,a" so that S, E, and N are integers and Y is a string. Then figure out which rows you want using logic on S and E, and for each row i use something like FIX(STRSPLIT(y[i], ',', /EXTRACT)) to get the list of years associated with it.
>
> -Jeremy.

Thanks a lot Jeremy !
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Contour Plot Error
Next Topic: IDLgrVolume rendering bug

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

Current Time: Wed Oct 08 09:22:25 PDT 2025

Total time taken to generate the page: 0.00618 seconds