Search code examples
pythonpython-2.7numpylabview

get channel name with nptdms


I use a npTDMS package (http://nptdms.readthedocs.org/en/latest/) for reading .TDMS files. The problem is that I want to get channel data with the syntax:

from nptdms import TdmsFile
tdms_file = TdmsFile("path_to_file.tdms")
channel = tdms_file.object('Group', 'Channel1')

As I understand I can also get the data with:

TdmsFile.channel_data('Group', 'Channel1')

I can get the 'Chanel1' with:

TdmsFile.group_channels(group)

But this returns:

[<TdmsObject with path /'name_of_the_group'/'name_of_the_channel'>]

The question7problem is: how can I get only

name_of_the_channel

from the above output?


Solution

  • Some time ago I had problems with reading the tdms files. Here is additional example that helped me, if anyone will have similar problems. Read tdms file:

    a = nptdms.TdmsFile("file_path.tdms")
    

    TDMS file has separate objects for the root and for each group and channel. The object method optionally takes a group and channel name argument so with:

    a.object().properties
    

    you're getting the properties of the root object. To get the properties of a channel you need to use:

    a.object('group_name', 'channel_name').properties