Menu

#651 input conversion error for lines ending with space carriage return

v1.0 (example)
closed
nobody
None
5
2018-04-19
2015-05-29
David Hoese
No

I'm fairly new to GDL and IDL (usually python or C) and I've run in to what I think is a bug. The following runs as expected in IDL, but not with GDL. I've gotten the problem down to this simple example with readf, but can't seem to recreate it with reads. The problem is when reading multi-line data from an ascii file using "readf" where lines are terminated with a space, carriage return, and newline; so ' \r\n'. The file comes from Windows and is being read on CentOS 6, GDL 0.9.5. If I use "fromdos" to remove the carriage return it works fine. If I remove the space it works fine.

File: test_read.pro

pro test_read,file
  openr,unit,file,/get_lun
  data2 = fltarr(4,2)
  readf,unit,data2
  print,data2
end

File: test_dos.txt (\r\n are actually newline characters)

0 -0.3360 1.000443  2.495156E-8 \r\n
1 14.6296 0.974881 -1.416588E-6 \r\n

Output of: gdl -e "test_read,'test_dos.txt'"

% Input conversion error.
      0.00000    -0.336000      1.00044  2.49516e-08
     -1.00000      1.00000      14.6296     0.974881

Output of: od -t c test_dos.txt

0000000           0       -   0   .   3   3   6   0       1   .   0   0
0000020   0   4   4   3           2   .   4   9   5   1   5   6   E   -
0000040   8      \r  \n           1       1   4   .   6   2   9   6    
0000060   0   .   9   7   4   8   8   1       -   1   .   4   1   6   5
0000100   8   8   E   -   6      \r  \n
0000110

Discussion

  • David Hoese

    David Hoese - 2015-05-29

    Actually I got it down even further and with reads:

    GDL> data2 = fltarr(1,2)
    GDL> s2 = '5 ' + string([13B, 10B]) + '5 ' + string([13B, 10B])
    GDL> reads,s2,data2
    % Input conversion error.
    GDL> print,data2
          5.00000
         -1.00000
    
     

    Last edit: David Hoese 2015-05-29
  • Sylwester Arabas

    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB