I have a 1GB file in a proprietary format that is a mix of ASCII characters and doubles (floating point numbers). I need to read in a sequence of twelve doubles. They are in consecutive bytes of the file starting at byte 5,043,340. What is a good way to get the values of those doubles using Mathematica?


1 Answer 1


Make sure you use the right format for you floating point reals. E.g. with "Real64", where every number take 8 Bytes, we can write 3 numbers and then jump to the second number by:

str = OpenWrite["d:/tmp/test.bin", BinaryFormat -> True];
BinaryWrite[str, {1., 2., 3}, "Real64"];
str = OpenRead["d:/tmp/test.bin", BinaryFormat -> True];
SetStreamPosition[str, 8];
BinaryRead[str, "Real64"]

(* 2 *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.