Re: Mixing ASCII and Binary in files [message #22490] |
Mon, 20 November 2000 00:00 |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Ben,
not sure whether it adds anything but traffic on the newsgroup ;-),
but you could perhaps make use of my Str2Byte routine which you find
on
http://www.mpimet.mpg.de/~schultz.martin/idl/html/libmartin_ schultz.html#Routines_S
It converts string scalars or arrays to byte arrays with a fixed
length so you can put them into a binary file.
Cheers,
Martin
Ben Tupper wrote:
>
> Thanks Liam and Kelly,
>
> Kelly, the method you describe is what I have used before. I'll try it
> again... I must have goofed up something simple (I hope).
>
> Liam, I check those procedures out. I don't know why I didn't think of it
> before... I have used BINread/write before.
>
> Ben
>
> Kelly Dean wrote:
>
>> I read and write combination ASCII and Binary files all the time in Windows
>> NT and Windows 2000. My prefer method is using structures.
>>
>> Kelly
>>
>> Ben Tupper wrote:
>>
>>> 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
>
> --
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 180 McKown Point Rd.
> W. Boothbay Harbor, ME 04575
> btupper@bigelow.org
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
Re: Mixing ASCII and Binary in files [message #22547 is a reply to message #22490] |
Wed, 15 November 2000 00:00  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Thanks Liam and Kelly,
Kelly, the method you describe is what I have used before. I'll try it
again... I must have goofed up something simple (I hope).
Liam, I check those procedures out. I don't know why I didn't think of it
before... I have used BINread/write before.
Ben
Kelly Dean wrote:
> I read and write combination ASCII and Binary files all the time in Windows
> NT and Windows 2000. My prefer method is using structures.
>
> Kelly
>
> Ben Tupper wrote:
>
>> 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
--
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 #22550 is a reply to message #22547] |
Wed, 15 November 2000 00:00  |
Kelly Dean
Messages: 92 Registered: March 1997
|
Member |
|
|
I read and write combination ASCII and Binary files all the time in Windows
NT and Windows 2000. My prefer method is using structures.
Kelly
Ben Tupper wrote:
> 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 #22552 is a reply to message #22547] |
Wed, 15 November 2000 00:00  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
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.
>
> I am able to read and write such files in MacOS using IDL without
> difficulty; I am unable to do the same in Windows.
Ben, did you try using the OPEN keywords /BINARY and /NOAUTOMODE in
Windows (I believe these keywords are no longer required in IDL 5.4).
> From within IDL, is it possible to write such a file so that it is
> readable across all platforms? If so, how?
BINWRITE and BINREAD are designed for this sort of thing. If you want to
include a string, convert it to BYTE type before writing it, and then
convert back to STRING type after reading it.
http://cimss.ssec.wisc.edu/~gumley/binarytools.html
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
|
|
|