I do not understand how IDL treats input fields consisting of white
space only when reading formatted data.
First I thought that IDL converts white space fileds to zeroes:
IDL> a = 0.0
IDL> b = 99.0
IDL> teststr = '6.0 '
IDL> reads,teststr,a,b,f='(f4.0,f6.0)'
IDL> print,a,b
6.00000 0.000000
Then I tried to read data from a table with white space for missing
values.
I read the lines as strings.
One line of data looks as follows:
; 1 2 3 4 5
;12345678901234567890123456789012345678901234567890123456789
;2 11234567890123 1 1123412123121234561234512345612345123456
1 F 92.178045955 S d 45.7 6.0
The scalar data variables are initialized to their respective data
types, then I try to read:
IDL> print,strlen(line)
60
IDL> reads,line,int1,str1,dbl1,str2,str3,int2,int3,int4,int5,flt1 ,$
IDL> flt2,flt3,flt4,flt5,$
IDL> f='(i2,1x,a1,f13.9,1x,a1,1x,a1,i4,i2,i3,i2,f6.2,f5.0,f6.0,f5 .0,f6.0)'
% Type conversion error: Unable to convert given STRING
to Float.
% Detected at: $MAIN$
% READS: End of input data encountered: LINE
% Execution halted at $MAIN$ (READS).
IDL> print,flt4
6.00000
Further inspection shows that the only variable not read correctly
is the last one, whereas the other white space fields have been
converted to zeroes.
Is this a bug, or have I made something wrong?
I use IDL 3.6.1 on a PC.
Yours,
Matthias Reuss
|