0

is there any way to convert csv to mdf4 with asammdf and transfer the header informations too?

When i create a mdf4 file with a modified version of this code

from asammdf import MDF
import pandas as pd

df = pd.read_csv('input.csv')

mdf = MDF()

mdf.append(df)

mdf.save('output.mf4')

then, there are default header entries. E.g.:

  • author

  • department

  • HDComment

  • MeasStartTime s Time since 1/1/1970

  • ...

How to delete this entries before creating the mdf file?

How to add own header entries out of the csv?

Example csv:

Customer   DummyCustomer
MeasName   DummyMeas
MeasCounter   25
Operator   DummyOperator
Time   DummyChannel1   DummyChannel2
0      0               75
1      2               85
2      14              88
3      21              87
4      33              88
5      45              89
6      21              89
7      83              89
8      32              89
9      22              89
10     70              90

The csv delimiter is tabstop.

William
  • 15
  • 1
  • 7

1 Answers1

0

You can set the attributes on the header

from asammdf import MDF
import pandas as pd

df = pd.read_csv('input.csv')

mdf = MDF()

mdf.header.author = 'the author'
mdf.header.department = 'dep'
mdf.header.project = 'prj'
mdf.header.comment = 'my comment'

mdf.append(df)

mdf.save('output.mf4')

see the codumentation here https://asammdf.readthedocs.io/en/master/v4blocks.html#asammdf.blocks.v4_blocks.HeaderBlock

danielhrisca
  • 665
  • 1
  • 5
  • 11
  • Thank you. I can only edit the existing attributes. How can i add new ones / delete existing ones? Is there any possibility to create entries, which are not time based (my code example)? "Customer = DummyCustomer" ... and so on. – William Nov 13 '19 at 06:49
  • Hi, I am facing the problem. Did you manage to find solution for this problem? – shripati007 Apr 07 '20 at 14:54
  • The MDF standard does not allow free style attributes like the HDF5 does. Instead, for custom data you should use the comment attributes of the header, data groups or channel groups to store them. – danielhrisca Apr 07 '20 at 15:20