Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
I am attempting to read a ASCII text file with topography data. This file was created on a DOS machine and has a CR and NL character after each line. In my attempts to read this file, I keep getting the CR and NL characters which messes up my image. Is there a way to read this file without picking up the CR and NL with IDL? Below is the sample PRO I am working with. The ASCII file is located on castor.cira.colostate.edu in Dean. Kelly Dean CSU/CIRA ============================================================ ==== PRO READ_TOP imgname = 'elev.txt' xsize = 961 ysize = 601 openr, unit, imgname, /get_lun status = FStat(unit) HELP, status, /STRUCT image = INTarr(xsize, ysize) scan = INTarr(xsize) FOR j = 0, ysize-1 DO BEGIN readU, unit, scan image(0,(ysize-1)-j) = scan ENDFOR close, unit free_lun, unit nmax = MAX(image) nmin = MIN(image) print, ' MAX ',nmax,' Min ',nmin WINDOW, 0, xsize=xsize,ysize=ysize,title='Elevation' TVscl, image end
dean@phobos.cira.colostate.edu wrote: : I am attempting to read a ASCII text file with topography data. : This file was created on a DOS machine and has a CR and NL character : after each line. In my attempts to read this file, I keep getting : the CR and NL characters which messes up my image. Is there a : way to read this file without picking up the CR and NL with IDL? : : Below is the sample PRO I am working with. The ASCII file : is located on castor.cira.colostate.edu in Dean. : : Kelly Dean : CSU/CIRA : If your using this data file on a Unix machice you can easily convert it using a standard text converter. SGI: to_unix SUN Solaris 2.x : dos2unix or use apropos on your system to see what's available, i.e., apropos "convert text" I used the SGI utility to_unix and got a clean image from your data. This solution seemed easier than converting the ASCII data within IDL. Scott Gennari -- ------------------------------------------------------------ ------ University of Hawaii voice (808) 956 5392 Dept. of Information & Computer Sciences fax (808) 956 9399 2565 The Mall, Keller 304A Honolulu, HI 96822 email gennari@Hawaii.Edu
dean@phobos.cira.colostate.edu wrote: > > I am attempting to read a ASCII text file with topography data. > This file was created on a DOS machine and has a CR and NL character > after each line. In my attempts to read this file, I keep getting > the CR and NL characters which messes up my image. Is there a > way to read this file without picking up the CR and NL with IDL? > > Below is the sample PRO I am working with. The ASCII file > is located on castor.cira.colostate.edu in Dean. > > ... Snip > > FOR j = 0, ysize-1 DO BEGIN > readU, unit, scan > image(0,(ysize-1)-j) = scan > ENDFOR Pardon me if I'm being obtuse, but why are you using an unformatted read (READU) on an ASCII file? IDL for Windows (and maybe other versions as well) eccepts either CR+LF or LF-only as line terminators in ASCII files. -- ============================================================ == Mark Hadfield hadfield@storm.greta.cri.nz NIWA (Taihoro Nukurangi) NIWA.GRETA:HADFIELD Wellington, New Zealand
Thanks for the input people. It appears I cannot use IDL to read pass the CR and NL. The c program that Amara Graps should be helpful. Unfortunely, I don't have access to a UNIX box - just a Window NT or VAX/VMS. Thanks again for the input, Kelly