MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: BinaryIO

  • To: mathgroup at
  • Subject: [mg57827] Re: BinaryIO
  • From: David Bailey <dave at>
  • Date: Thu, 9 Jun 2005 05:18:42 -0400 (EDT)
  • References: <d86b4j$dgs$>
  • Sender: owner-wri-mathgroup at

Marko Kastens wrote:
> Hi,
> I have just updated to Mathematica and trying the new BinaryIO-Commands to 
> increase the IO speed. But ... here is something strange:
> n = 1000000;
> TSout = Table[{FromDate[{2000, 1, 1, 0, 0, 0}] + i, Random[]}, {i, n}];
> BinaryWrite["binTS.dat", TSout, {"Real64", "Real64"}]; // Timing
> TSin = BinaryReadList["binTS.dat", {"Real64", "Real64"}]; // Timing
> TSout == TSin
> Evaluating these lines with a fresh kernel: everything is ok. Evaluate them a 
> second time and TSout==TSin produce a _False_. Restarting the kernel: 
> everything is ok. 
> Every time I (try to) overwrite the file _binTS.dat_ I got a False. It seems to 
> me that the routine is not able to overwrite files.
> Hmmm, any suggestions?
> marko
The problem with using BinaryWrite (or indeed Write) with a file name as 
its first argument is that there is no clear concept of closing the 
files. Create a stream


Then you can use that as the argument to BinaryWrite. After that, use 
Close to close the stream and re-open the file with 
OpenRead[binTS.dat",BinaryFormat->True] to read it back. Finally, close 
it again. This is a little bit more work, but Mathematica knows exactly 
what you want it to do with the files.

David Bailey

  • Prev by Date: Preventing LegendreP from self-extracting in manipulations
  • Next by Date: Re: goto and label (cont)
  • Previous by thread: Re: BinaryIO
  • Next by thread: string to a special list