danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
655 stars 226 forks source link

Creating mdf file from pandas dataframe #1060

Closed bojan777 closed 3 months ago

bojan777 commented 4 months ago

Python version

'python=3.8.11 (default, Aug 6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)]' 'os=Windows-10-10.0.19045-SP0' 'numpy=1.22.4' 'asammdf=7.0.3'

Code

mdf_obj = asammdf.MDF(test_file.mdf)

df = mdf_obj.to_dataframe() outputMdf = asammdf.mdf.MDF() outputMdf.append(df)

outputMdf.save('output_mdf')

MDF version

3.2

Description

I am trying to create an mdf file from a pandas dataframe, but have not been able to create a valid mdf file (I am not able to view the output file using vector CANape software).

In the code I provided above i am taking a "good" mdf file (file that I am able to open using vector CANape ) and creating a pandas dataframe from this file, then creating a new mdf file and appending the dataframe to it. I save the new file and don't get errors, I was expecting the output file to be identical to original file but I am not able to view the new file in CANape, new file is also 10x larger than original. If I load the the new file back into a python and create a dataframe, this dataframe does look identical to a dataframe created from orginal file.

danielhrisca commented 3 months ago

I can't reproduce the problem with my files, so please send yours for debugging

bojan777 commented 3 months ago

I sent the files, thank you.

bojan777 commented 3 months ago

I fixed this by converting the output file to mdf version 3.20, it looks like issue was with canape reading version 4.10 mf4 file which was the default output format