4
$\begingroup$

I am trying to import a binary data file. It seems that BinaryReadList would be appropriate? However the data file is composed of c++ structures like this:

struct data1 {
    uint8_t    field1;
    uint16_t   field2;
    uint32_t   field3;
};

struct data2 {
    uint16_t   field1;
    uint16_t   field2;
    uint8_t    field3;
    uint32_t   field4;
};

struct data {
    data1  entry1;
    data2  entry2;
    data2  entry3[10];
};

int main() {

data myData[100];

}

Is there a way to specify the expected input format to read the data appropriately? I couldn't find a decent solution to import these data with Mathematica ?

$\endgroup$
  • 4
    $\begingroup$ Have you tried the third syntax format of BinaryReadList (BinaryReadList["file",{type1,type2,...}])? If so, did it work for you or did you encounter any problems? $\endgroup$ – Sjoerd C. de Vries Aug 30 '15 at 20:26
  • $\begingroup$ Thx a lot , i did overlook this option :) $\endgroup$ – bernddude Aug 31 '15 at 2:08
2
$\begingroup$

As per the comment, the third syntax format of BinaryReadList does what is required:

BinaryReadList["file",{type1,type2,...}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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