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 #92174 is a reply to message #92172] Fri, 23 October 2015 04:52 Go to previous messageGo to previous message
Kai Heckel is currently offline  Kai Heckel
Messages: 51
Registered: April 2015
Member
Am Freitag, 23. Oktober 2015 11:25:37 UTC+2 schrieb Helder:
> 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

Thanks Helder!

But I'd like to have the strings in the 1st column and the according float value in the 2nd column... I looked it up under FORMAT but I couldn't find the right thing. Do you have a solution for this?

Cheers,
Kai
[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: Fri Oct 10 14:04:40 PDT 2025

Total time taken to generate the page: 0.64095 seconds