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

Home » Public Forums » archive » READ array from a file
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: READ array from a file [message #93134 is a reply to message #93118] Sun, 01 May 2016 00:24 Go to previous messageGo to previous message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
On Friday, April 29, 2016 at 10:12:18 AM UTC+5:30, Zachary Norman wrote:
> If you only have spaces ONLY between the name and the two arrays, then you can read the text file as a string array with:
>
> ;pre-allocate string array
> infile = 'C:\some\file.txt'
> nlines = file_lines(infile)
> strings = strarr(nlines)
> openr, lun, infile, /get_lun
> readf, lun, strings
> free_lun, lun
>
>
> Then you can split each line with:
>
>
> splitline = strsplit(strings[0], /extract)
> name = splitline[0]
> arr1 = splotline[2]
> arr2 = splitline[3]
>
>
> I'll let you figure out the rest for how you get the string representation of the arrays into actual arrays.

Yeah I tried this ..... worked fine...now the problem is
arr1= splitline[1] is an string array i don't know how to convert it into float array.
i tried with..
arr1= fltarr(splitline[1])
but its showing invalid type conversion. Any way out???
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: READ ARRAY and extract the values
Next Topic: NetCDF4 problem

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

Current Time: Fri Oct 10 06:54:48 PDT 2025

Total time taken to generate the page: 1.19890 seconds