To append to a csv or a txt file, you can open the file using the OPENW or OPENU routines with the APPEND keyword. Then you can write to the file using the PRINTF routine. A short example, is included below:
pro ex_append_txt
COMPILE_OPT IDL2
;Quick example
openw, lun, "FishRfun.txt", /GET_LUN ; create the file
printf,lun, "Top of FishRfun file!"
printf,lun, "Closing File!"
free_lun, lun ;close the file
openu, lun, "FishRfun.txt", /GET_LUN, /APPEND ;reopen file to read and write with Append keyword
printf, lun, "File reopened with APPEND keyword!"
i = 3
b = FINDGEN(i)
for i= 0,i-1 do begin
a = 2*i
b[i] = a*2
printf, lun, a, " ", b ; write the variable values to the end of the file
endfor
free_lun, lun ; closes the file
end
|