[Python] Read a measurement binary file with Python [closed]

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    i have a binary measurement file (there should be floats/int in it, a left side and a right side. From the measurement system (PAK, it is for testing sound pressure for vehicles etc) there is also an theader.xml file. Someone pointed that with this theader.xml it is possible to convert the binary file but doesnt know how. I think the relevant information from the xml file is this:

    <segment_layout>
    <scan_size>32768</scan_size>
    <values_per_block>4096</values_per_block>
    <block_offsets>0 16384</block_offsets>
    </segment_layout>
    <segment>
    <file>PAK_Throughput0/mea_throughput0</file>
    <number_of_values>548224</number_of_values>
    <inioffset>8</inioffset>
    <t0>-1.3999999986666667e+00</t0>
    </segment>


    So the block offsets line for example. Offset 0 is for left side, offset 16384 for the right side. But how can i read it in python? I know python relatively good, but not much with binary files. I know to read it like, simple...

    with open(fileName, mode='rb') as file:
    fileContent = file.read()


    But how can i read for example only the needed blocks and so on? Also this information:

    <scan_size>32768</scan_size>
    <values_per_block>4096</values_per_block>


    Perhaps someone can help alittle bit with this? Many thanks. I think for someone who worked with binary files much it is an easy task i hope. The sample theader.xml is here: https://pastebin.com/MPRY4VBa I uploaded a binary file here: https://filebin.net/nvsypt9ya73v5jjr It is the mea_throughput0 from the PAK_Throughput0 folder that is referenced in the xml file.

    Would be great if anyone can help with that.

    Regards and thanks

    Continue reading...

Compartilhe esta Página