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

Home » Public Forums » archive » Writing 2 arrays of a different type into one text 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: Writing 2 arrays of a different type into one text file [message #92172 is a reply to message #92171] Fri, 23 October 2015 02:25 Go to previous messageGo to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Friday, October 23, 2015 at 10:10:38 AM UTC+2, Kai Heckel wrote:
> Hello!
>
> Is it possible to write 2 arrays into one text file?
> What I have are 2 arrays: 1) float, 2) string.
> I would like to write the string array into the 1st column and the float array into the 2nd column. Is this somehow possible?
>
> Thanks in advance
>
> Cheers,
> Kai

Yes.
arrayFloat = randomu(s, 10)
arrayStrings = strtrim(findgen(10),2)
fileName = 'testFileOutput.txt'
get_lun, fileUnit
openw, fileUnit, fileName
printf, fileUnit, transpose(arrayStrings+', '+string(arrayFloat,FORMAT='(f0.3)'))
close, fileUnit
free_lun, fileUnit

Play a bit around with string() and the format keyword. A way or another, you will get what you want (constant width for the columns or number of decimals, separator, ...).

Cheers,
Helder
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Clip 2D Array in IDL
Next Topic: Read irregular data problem

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

Current Time: Wed Oct 08 17:27:42 PDT 2025

Total time taken to generate the page: 0.00645 seconds