03-19-2021 04:22 AM
Some years ago I developed an application in LabVIEW which hadnles some data in a LabVIEW cluster and saves them to a binary file dumping the cluster to the file.
Now one of my customers asks me to read that file with Python.
Is there a way to do this?
Thanks
Solved! Go to Solution.
03-19-2021 04:43 AM
Hi vix,
@vix wrote:
Some years ago I developed an application in LabVIEW which hadnles some data in a LabVIEW cluster and saves them to a binary file dumping the cluster to the file.
Now one of my customers asks me to read that file with Python.
Is there a way to do this?
Yes.
Look up how your old application saved those data, i.e. determine the exact cluster datatype.
Then try to read the cluster elements from your binary file…
Mind to attach both the cluster and some example data files?
03-19-2021 05:16 AM
Hi GerdW,
I attach a LV 2020 vi which saves some dummy data, so that you can see the exact cluster datatype.
If you run the vi, a binary file is dumped.
Is there a library in Python to read from LabVIEW cliusters?
I wonder about padding and such kind of thigs that happens behind the scenes when working with binary dumps.
03-19-2021 05:25 AM
Hi vix,
@vix wrote:
I attach a LV 2020 vi which saves some dummy data, so that you can see the exact cluster datatype.
Is there a library in Python to read from LabVIEW cliusters?
I wonder about padding and such kind of thigs that happens behind the scenes when working with binary dumps.
I can't open this right now.
Can you attach the original VI? Dumping binary data might change from LabVIEW version to version! See the hassles with Datalog files, which include a notification of the LabVIEW version used for saving…
03-19-2021 05:28 AM
Hi Gerd,
I attach the LabVIEW 2012 version.
The original application is in LabVIEW 2012.
Let me know if you can open this.
03-19-2021 07:12 AM - edited 03-19-2021 07:19 AM
Hi vix,
oh boy!
I guess it will be easier to write a LabVIEW routine to convert that cluster into some XML or JSON or even handcrafted text format instead of trying to read this binary files directly with Python!
See this:
The first cluster contains arrays, with 2 elements in them. The binary file starts with "00000002 0000000B 0000006F" for the very first array in the very first subcluster (2 elements, integer items with value 11=0B and 111=6F). I don't see an indication of the cluster, so your Python routine will have a hard time to recognize the clusters in your data files… (LabVIEW writes I32 length parameters for arrays and strings, a path converts to an array of strings with a different kind of length encoding, and so on.)
Or the other way around: your Python routine needs to know the exact order of elements in your huge cluster and needs to detect and parse each element. Those waveforms can become trickier, when they also carry (an unknown number of) attributes…