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

Home » Public Forums » archive » Re: Writing ASC/TXT file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Writing ASC/TXT file [message #78496] Tue, 22 November 2011 05:15
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mr.AlaaD writes:

> My question should not be difficult. I have an ascii/txt file that has
> 5 columns (numbers) and what I want to do is to open this file and
> write a sixth column. I tried to do it but I do not know why it is
> written under the first column (as a continuous of the first column)
> instead of writing a new sixth column.

file = 'mydata.txt'
rows = File_Lines(file)
data = Fltarr(5,rows)
OpenR, lun, file, /Get_lun
ReadF, lun, data
Free_Lun, lun
columntoAdd = Findgen(rows)
newData = [data, Reform(columnToAdd, 1, rows)]
OpenW, lun, file, /Get_Lun
PrintF, lun, newData
Free_Lun, lun

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Writing ASC/TXT file
Next Topic: IDL 8.1, X11 and Crashes

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

Current Time: Fri Oct 10 08:13:49 PDT 2025

Total time taken to generate the page: 0.08378 seconds