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

Home » Public Forums » archive » Re: ignoring the strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: ignoring the strings [message #89673] Tue, 11 November 2014 00:17
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, November 10, 2014 11:55:46 PM UTC+1, luc...@gmail.com wrote:
> Hello I have some data in the following format in a text file
> ____________________________________________________________ _______
> #HEADER
> #info
> #info
> # X values (counts): 0.7 1 1.2 2 2.5 2.7 3 5 5.3 8
> #info
> #day,yvalue1,yvalue2,yvalue3,yvalue4,yvalue5,yvalue6y,value7 ,yvalue8,yvalue9,yvalue10
> 1,500,501.1,502.22,499.01,501.36,500.03,501.25,499.365,499.6 3,499.99
> .
> .
> .
> 100,499.55,498.20,501.22,500.23,501.33,500.24,501.12,499.52, 501.98,499.1
> .
> .
> .
> ___________________________________________________________
> So I want to extract the data in 3 different vectors only for day 1 and day 100, but I have a ton of other data in the file.
>
>
> xvalues=[]
> yvalues_day1=[]
> yvalues_day100=[]
>
> any suggestions how to do this?

what have you tried and what has not worked?
You can find some info on how to read text files here: http://www.idlcoyote.com/tips/ascii_column_data.html

Once you get past the header, you can read each line, check if it is number 1 or 100 and if so then handle consequently (for instance using the strsplit function with the extract and count keywords).

in other words, read a line
line = ''
readu, unit, line
strArr = strsplit(line, ',', /extract, count=count)
if count gt 1 then begin
if long(strArr[0]) eq 1 then begin
print, 'this is line 1'
yvalues_day1=long(strArr[1:-1])
endif
if long(strArr[0]) eq 100 then begin
print, 'this is line 100'
yvalues_day100=long(strArr[1:-1])
endif
endif

enjoy idl.

Helder
[Message index]
 
Read Message
Previous Topic: PostScript Encapsulation Knowledge
Next Topic: NOCLIP in XYOUTS not working with !P.FONT

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

Current Time: Wed Oct 08 14:10:24 PDT 2025

Total time taken to generate the page: 0.00259 seconds