[gradsusr] GRADS txt file, substr, looping

James T. Potemra jimp at hawaii.edu
Wed Sep 14 15:52:04 EDT 2016


Luciano,


I think you need to first subset by word (using subwrd; defined by 
spaces); in this case,


var1 = subwrd(line1,3)

var = substr(var1,28,4)


Jim


On 9/14/16 7:47 AM, Luciano Ritter wrote:
> Hi
>
> I am trying to read a data file in .txt and extract the information 
> that I need.
> I read the file trough the function 'read', but the problem is that i 
> can't extract the information.
> The format of the data is:
> line1 = 83844;01/01/2000;1200;57.6;23.6;22.8;93;0;0;
> line2 = 83844;01/01/2000;1800;;23.6;22.6;91;18;6.6;
> line3 = 83844;02/01/2000;0000;;22;21.3;93;18;4.6;
> line4 = 83844;02/01/2000;1200;51.4;23.2;21.7;87;18;3.3;
>
> I need to extract only 23,6 ; 23,6 ; 22 ; 23,2 of the first, second, 
> third and fourth lines. I was trying with the intrinsic function, for 
> example to the first line:
>
> var = substr(line1,28,4)
>
> var = 23,6
>
> If it was only those 4 lines, i could do manually but they are 10200 
> lines. So, I think i need some loop with 'while' variating the substr 
> function, but i don't know how to do this.
>
> Someone can help me?
>
> Thanks a lot.
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20160914/6830fc93/attachment.html 


More information about the gradsusr mailing list