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