Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mf4 to csv conversion in python

I have a dataset of mf4 and I want to convert it into CSV in python. I have read the data from mf4 and convert it into csv (as given below) but I am getting an error, as I am new to python, so unable to find an appropriate method to convert.

from asammdf import MDF
import pandas as pd

efficient = MDF('./Data.mf4')

df = efficient.to_csv()


df.append(efficient)

mdf.save('output.csv')

I am getting this error:

MdfException: "Data.mf4" is not a valid ASAM MDF file: magic header is b'timestam'

Kindly suggest. Thank you!

like image 906
jaz Avatar asked Oct 23 '25 09:10

jaz


1 Answers

You can use the asammdf package, either by using the API or the GUI.

Install the package and the GUI dependencies:

pip install asammdf[gui]

API usage

from asammdf import MDF
mdf = MDF('input.mf4')
mdf.export(fmt='csv', filename='output.csv')

There are other export options that you can use, please check the documentation https://asammdf.readthedocs.io/en/latest/api.html#asammdf.mdf.MDF.export

GUI

Start the GUI from the python_installation_folder\Scripts\asammdfgui.exe or by running this script

from asammdf.gui.asammdfgui import main
main()

enter image description here

like image 111
danielhrisca Avatar answered Oct 25 '25 00:10

danielhrisca