Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading TDMS files in python_ how to use tdmsinfo command?

Tags:

python

labview

I would like to know what is the content of a tdms file, which is produced by Labview.

Following this site, I write in Python:

import numpy as np
from nptdms import TdmsFile
from nptdms import tdms

#read a tdms file
filenameS = "RESULTS.tdms"
tdms_file = TdmsFile(filenameS)

tdmsinfo [--properties] tdms_file

I receive the following error:

tdmsinfo [--properties] tdms_file
                                    ^
SyntaxError: invalid syntax

I do not how to fix it.

Thank you for your help :)

like image 337
user8224662 Avatar asked Dec 31 '25 10:12

user8224662


1 Answers

What you are looking for is:

First create a TMDS objet from file:

tdms_file = TdmsFile("C:\\Users\\XXXX\\Desktop\\xx Python\\XXXX.tdms")

then get the group names with:

tdms_groups = tdms_file.groups()

after you can figure out which group names you have into the file, just write

tdms_groups

It will print the following:

['Variables_1', 'Variables_2', 'Variables_3', 'Variables_4', etc..]

With group names now u will be able to get channels with the following:

tdms_Variables_1 = tdms_file.group_channels("Variables_1")

Next print your channels contain into that group:

tdms_Variables_1

It will show:

[ TdmsObject with path /'Variables_1'/'Channel_1', TdmsObject with path /'Variables_1'/'Channel_2', etc..]

At the end get the vectors and its data:

MessageData_channel_1 = tdms_file.object('Variables_1', 'Channel_1')
MessageData_data_1 = MessageData_channel_1.data

Check your data

MessageData_data_1

do stuff with your data! cheers!

like image 126
JNey Avatar answered Jan 02 '26 23:01

JNey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!