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

Home » Public Forums » archive » Re: Writing formatted text files
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 formatted text files [message #18889 is a reply to message #18885] Fri, 11 February 2000 00:00 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Bernard Puc <bpuc@va.aetc.com> wrote in message
news:38A47BCA.884D0CC@va.aetc.com...
> I'd like to speed-up the following code. I'm writing comma delimited
> text files, I'm eliminating whitespace by using strtrim, and am
> explicitly formatting the string using a format keyword. Any ideas how
> to improve this? I've been playing with various ways of formatting
> without using a FOR loop but either don't get the desired output or the
> error message telling me the output string has been truncated to 1024
> lines.
>
> data_to_write = fltarr(3, 100000)
> FOR j=0, 99999 DO BEGIN
> PRINTF,Lun,$
> strtrim(string(data_to_write[0,j],format='(f10.3)'),2),',',$
> strtrim(string(data_to_write[1,j],format='(f10.3)'),2),',',$
> strtrim(string(data_to_write[2,j],format='(f10.3)'),2),$
> FORMAT = "(a,a,a,a,a)"
> ENDFOR
>
> Output should look like this:
>
> 278.980,-232.018,258.090
> 278.926,-231.974,258.360
> 278.889,-231.944,241.240
> 278.852,-231.913,206.900
> 278.814,-231.883,156.390
> 278.776,-231.852,93.680
> 278.739,-231.821,27.799
> 278.702,-231.791,-33.771
> 278.664,-231.760,-84.551
> 278.626,-231.729,-121.161

This doesn't get rid of all the whitespace, but it's simple and quick, and
the output is easy to read:

arr = findgen(3, 1000) * 0.1
print, arr, format='(2(f8.3, ","),f8.3)'

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: Re: REPLICATE with arrays
Next Topic: Writing formatted text files

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

Current Time: Wed Oct 15 16:20:57 PDT 2025

Total time taken to generate the page: 0.96223 seconds