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

Home » Public Forums » archive » Read_ASCII and 'invalid' ascii files
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
Read_ASCII and 'invalid' ascii files [message #41949] Fri, 10 December 2004 11:01 Go to next message
jaden is currently offline  jaden
Messages: 3
Registered: December 2004
Junior Member
Hi Everyone,

I have been using IDL's read_ascii function to read in data files
using a template. The only problem is that all the source files have a
+/- symbol in the header, and IDL reports that these files are not
valid ascii files, when they clearly are. When I open with a text
editor, and remove the suspect character, the function runs perfectly.
Any suggestions?

Jaden
Re: Read_ASCII and 'invalid' ascii files [message #42046 is a reply to message #41949] Fri, 10 December 2004 12:14 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
>> I have been using IDL's read_ascii function to read in data files
>> using a template. The only problem is that all the source files have a
>> +/- symbol in the header, and IDL reports that these files are not
>> valid ascii files, when they clearly are. When I open with a text
>> editor, and remove the suspect character, the function runs perfectly.
>> Any suggestions?
>>
>> Jaden
>
>
> I think the ASCII code defines only 128 characters (7 bit). The +/- sign
> is part of an "extended" ASCII code, which makes use of the 8th bit but
> is not strictly defined.

There's a pretty standard technique for determining whether a file is
ASCII or binary. Basically, you look at the bytes within the file and
determine what percentage of the bytes fall into the printable standard
ASCII range. If this percentage is really high, you can guess that the
file is probably text. Otherwise the file is probably binary. It
appears that IDL's check is a lot more rigorous. If any byte falls
outside printable standard ASCII, it's throwing the error you see.

Now, what to do about it? I don't know what system you're on, but if
you're using *nix, you can use a simple little sed command to remove or
replace the plus/minus sign. For example, the following command finds
all occurrences of the plus/minus, removes them and saves the result in
a new file.

$ sed "s/�//" file.txt > new_file.txt

-Mike
Re: Read_ASCII and 'invalid' ascii files [message #42048 is a reply to message #41949] Fri, 10 December 2004 11:15 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
Jaden wrote:
> Hi Everyone,
>
> I have been using IDL's read_ascii function to read in data files
> using a template. The only problem is that all the source files have a
> +/- symbol in the header, and IDL reports that these files are not
> valid ascii files, when they clearly are. When I open with a text
> editor, and remove the suspect character, the function runs perfectly.
> Any suggestions?
>
> Jaden

I think the ASCII code defines only 128 characters (7 bit). The +/- sign
is part of an "extended" ASCII code, which makes use of the 8th bit but
is not strictly defined.

Benjamin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Stretching an image
Next Topic: Help with Nested FOR Loop

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

Current Time: Thu Oct 09 20:10:32 PDT 2025

Total time taken to generate the page: 0.16114 seconds