Reputation: 1
I have been tried to write 8 columns in a CSV file by using IDL, but seems the maximum columns that I can wrote is 7?
IDL> write_csv,ffout,date_time,tmin_tmax,precp,wind,rh,sun_hrs,glb_rad,net_rad
WRITE_CSV: Incorrect number of arguments
Upvotes: 0
Views: 1425
Reputation: 387
As long as your input arrays are one-dimensional you can just concatenate them (and do an additional transpose):
a = FINDGEN(3)
b = TRANSPOSE([ [a], [a], [a], [a], [a], [a], [a], [a], [a], [a] ])
WRITE_CSV, 'test.csv', b
Upvotes: 0
Reputation: 2386
The documentation for WRITE_CSV
indicates you can write up to 8 columns, which works for me:
x = findgen(10)
write_csv, 'test.csv', x, x, x, x, x, x, x, x
In any case, if you need to write more columns, it is easy enough to use PRINTF
to output each line:
for i = 0L, n_lines - 1L do begin
printf, lun, a[i], b[i], c[i], d[i], e[i], f[i], g[i], h[i], $
format='(%"%f, %f, %f, %f, %f, %f, %f, %f")'
endfor
You can change the format codes as appropriate, or use the Fortran-style format codes as you prefer.
Upvotes: 1