MathGroup Archive 2009

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

Search the Archive

BinaryReadList

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99536] BinaryReadList
  • From: Hannes Kessler <HannesKessler at hushmail.com>
  • Date: Thu, 7 May 2009 06:37:30 -0400 (EDT)

Hello,

before Mathematica 7 the following command could be used to return the
contents of a binary file as a list of records, each record being a
nested list of a certain structure, for example

BinaryReadList[file,{"Integer32", {"Real64", "Real64"}, "Integer32"}]

Mathematica 7 complains:

BinaryReadList::format {"Integer32", {"Real64", "Real64"},
"Integer32"} is not a recognized binary format.

I know there are other ways (see below one suggestion). But what is
the purpose to eliminate useful existing functionality in new
Mathematica revisions?

Here is my workaround:

format = {"Integer32", {"Real64", "Real64"}, "Integer32"};
data = BinaryReadList[file, Flatten  @  format];
formats = ConstantArray[format, Length[data]];
positions = Position[formats, _String];
rules = Inner[Rule, positions, Flatten[data], List];
ReplacePart[formats, rules]

Best regards,
Hannes Kessler


  • Prev by Date: Re: Given a matrix, find position of first non-zero element in each
  • Next by Date: Re: Re: programmatically rotating a function plot
  • Previous by thread: Re: Given a matrix, find position of first non-zero element in each
  • Next by thread: Re: BinaryReadList