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

Home » Public Forums » archive » Writing a modified .txt file issue
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: Writing a modified .txt file issue [message #85374 is a reply to message #85370] Mon, 29 July 2013 13:55 Go to previous messageGo to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I haven't really tested this, but now STRSPLIT() can operate on a 2-d array and return the values in a list. So you can eliminate loops entirely

mylist = strsplit(word,' ',/extract)
myarr = mylist.toarray()
data.date = myarr[*,0]
data.time = myarr[*,1]
data.latitude = double( myarr[*,2])
data.longitude = double( myarr[*,3])

On Monday, July 29, 2013 4:03:02 PM UTC-4, Phillip Bitzer wrote:

> FOR i=0L, nLines-1 DO BEGIN
>
> this_row = STRSPLIT(word[i], ' ', /extract)
>
> data[i].date = this_row[0]
>
> data[i].time = this_row[1]
>
> data[i].latitude = DOUBLE(this_row[2])
>
> data[i].longitude = DOUBLE(this_row[3])
>
> ....
>
> ENDFOR
>
>
>
> I have been looking for a better/more efficient way of doing this. Can't seem to find a good way, but maybe Coyote has cooked up something :-) ReadCol works about as quickly as my code.
>
>
>
> I should mention that there are several string columns mixed up amongst the numeric columns. Yuck.
>
>
>
> For the output, Hakan, I would say those numbers *do* match, although they might be formatted differently. You'll want to use the FORMAT keyword, however you're writing the file back out if you want to match the numbers/decimal places/etc.
>
>
>
> A simple example:
>
> IDL> a = 13.2
>
> IDL> PRINT, a
>
> 13.2000
>
> IDL> PRINT, a, format='(F5.2)'
>
> 13.20
>
> IDL> PRINT, a, format='(F4.1)'
>
> 13.2
>
>
>
> You would do something similar using PRINTF.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Find all user-defined structure definitions
Next Topic: Multiple plots with plot function

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

Current Time: Sat Oct 11 11:15:12 PDT 2025

Total time taken to generate the page: 1.81930 seconds