comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Reading ASCII
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Reading ASCII [message #4706] Fri, 21 July 1995 00:00 Go to next message
dean is currently offline  dean
Messages: 55
Registered: March 1993
Member
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
Re: Reading ASCII [message #4777 is a reply to message #4706] Thu, 27 July 1995 00:00 Go to previous message
dean is currently offline  dean
Messages: 55
Registered: March 1993
Member
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
Re: Reading ASCII [message #4798 is a reply to message #4706] Sun, 23 July 1995 00:00 Go to previous message
gennari is currently offline  gennari
Messages: 25
Registered: April 1994
Junior Member
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
Re: Reading ASCII [message #4799 is a reply to message #4706] Sun, 23 July 1995 00:00 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Question about MOMENT
Next Topic: Program code area exceeded?? 50k file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:32:52 PDT 2025

Total time taken to generate the page: 0.00488 seconds