Re: Writing ASC/TXT file [message #78496] |
Tue, 22 November 2011 05:15 |
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.")
|
|
|