How to get a list of all the channel names in a .mdf4 file while using asammdf? I read the description here but am unable to figure out the exact code.
Asked
Active
Viewed 1,741 times
0
-
Are you on purpose not reading the [most recent](https://asammdf.readthedocs.io/en/latest/) version of the documentation? – mkrieger1 Jun 29 '22 at 15:45
1 Answers
0
According to https://asammdf.readthedocs.io/en/latest/api.html#mdf4:
The groups attribute is a list of dicts, each one with the following keys:
- […]
channels
- list of Channel objects with the same order as found in the mdf file
And according to https://asammdf.readthedocs.io/en/latest/v4blocks.html#channel-class a Channel object has attributes
display_name
- str : channel display name; this is extracted from the XML channel commentname
- str : channel name
So you should be able to use:
mdf4 = MDF4(name_of_mdf4_file)
all_channels = []
for group in mdf4.groups:
for channel in group['channels']:
all_channels.append(channel.display_name)
Or use .name
instead of .display_name
, depending on what exactly you need.

mkrieger1
- 19,194
- 5
- 54
- 65