comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: ignoring the strings

Re: ignoring the strings
type: item
description: 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
creator: Helder Marchetto
date: 2014-11-11T08:17:14-00:00