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

Home » Public Forums » archive » Mixing ASCII and Binary in 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
Mixing ASCII and Binary in files [message #22553] Wed, 15 November 2000 00:00 Go to next message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
Hello,

Thank you for all for the very interesting responses regarding my Julian
Day number query.

I have a question regarding mixing ASCII data (as a header) with binary
data (as data following the header). This is a desirable format for our
purposes for a number of reasons. I have come across such files
generated in the DOS environment from Sea-Bird Electronics devices.

I am able to read and write such files in MacOS using IDL without
difficulty; I am unable to do the same in Windows.

From within IDL, is it possible to write such a file so that it is
readable across all platforms? If so, how?

Thanks

Ben

--
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org
Re: Mixing ASCII and Binary in files [message #22611 is a reply to message #22553] Tue, 21 November 2000 00:00 Go to previous messageGo to next message
Rob Preece is currently offline  Rob Preece
Messages: 4
Registered: April 2000
Junior Member
In article <3A12C270.FB129412@ssec.wisc.edu>, "Liam E. Gumley"
<Liam.Gumley@ssec.wisc.edu> wrote:

> Ben Tupper wrote:
>> I have a question regarding mixing ASCII data (as a header) with binary
>> data (as data following the header). This is a desirable format for our
>> purposes for a number of reasons. I have come across such files
>> generated in the DOS environment from Sea-Bird Electronics devices.
>>
<snip>

> Of course if you want to go full steam on this, you may want to consider
> netCDF or HDF.
>
> Cheers,
> Liam.
> http://cimss.ssec.wisc.edu/~gumley

Or use FITS (Flexible Image Transport Something), available within the
Astronomy users library. I have had no problem carting my FITS data
files all over the OS roadmap: VMS, Linux, Mac and PeeCee.

- Rob


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
Re: Mixing ASCII and Binary in files [message #22653 is a reply to message #22553] Tue, 28 November 2000 00:00 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
Hello,

I hate to post a follow-up so long after the original post first appeared.
I was the original poster-person (posterizer, posterer?) I seem to be
behind the eight ball a wee-bit. I haven't had the chance to get back to
this until just now.

To write the file:

;first write the header
OpenW, U, FileName, /NoAutoMode, /Get_LUN ;open as a text file
PrintF, U, ASCIIDataHERE, ..... my stuff included a multi-field structure
with tag names
Free_LUN, U ;close the file

;now the binary data
OPENU, U, FileName, /NoAutoMode, /Binary, /Append, /Get_LUN ;open
as binary
WriteU, U, BinaryDataHERE ;append the data
Free_LUN, U ;close the file

To read the above file:

;first read the header
OpenR, U, FileName, /NoAutoMode, /Get_LUN ;open as text
file
ReadF, U, ASCIIdataHere, ....
F = FSTAT(U) ;capture the file state (in particular the
current pointer position)
Free_LUN, U

;now read the binary data
OpenR, U, FileName, /NoAutoMode, /Binary, /Get_LUN ;open as binary
Point_LUN, U, F.Cur_Ptr ;advance the file pointer to
end of header
ReadU, U, BinaryDataHere
Free_LUN, U


It seems to work just fine now. A simple series of steps, soon to be
obselete when IDL 5.4 arrives in time for the holidays.

Now, I wonder if it's too late to send in my absentee ballot?

Ben

--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: DDE
Next Topic: Re: Bad data in structure (NaN HowTo?)

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

Current Time: Wed Oct 08 09:14:45 PDT 2025

Total time taken to generate the page: 0.00454 seconds