npTDMS Python 模块未获取所有通道属性
npTDMS Python Module not getting all channel properties
我正在使用 npTDMS Python 模块读取 TDMS 文件,但在获取所有通道属性时遇到问题。我可以使用 Scout 或 DIAdem 甚至内置的 LabVIEW 查看器打开我的 TDMS 文件,我可以看到文件中的每个通道(时间和压力)都有四个属性:NI_ArrayColumn、NI_ChannelLength、 NI_DataType,和姓名。但是,下面的代码只输出
OrderedDict([('NI_ArrayColumn', 1)])
代码如下:
from nptdms import TdmsFile
tdms_file = TdmsFile("2017-10-16;12.37.05_Pressure (1).tdms")
channel = tdms_file.object('Scan', 'Pressure')
print(str(channel.properties))
其他三个属性在哪里?
我发现 npTDMS
模块处理即时生成的属性的方式与内置 LabVIEW 查看器、Scout、DIAdem 和 Excel 添加的方式不同- 在做。这对我来说似乎是一个错误,所以我有一个 issue reported on the github。
我不知道以下代码片段是否回答了您的问题(也许错误已经得到纠正),但我发现 npTDMS 模块在检索动态生成的组属性时工作正常。
##Importing necessary packages.
import numpy as np
import nptdms
##Opening TDMS file.
file = nptdms.TdmsFile(my_file)
##Gets all file objects (group entities); each 'key/value' pair comprises a path and an object pointing to a group on the file.
fileObjs = list(file.objects.items())
##For each object (group), the written properties are retrieved and listed. The indexing is set to skip the root group.
for i in range(1, len(fileObjs)):
list(fileObjs[i][1].properties.items())
############################################################################
############################################################################
##Or, using list comprehension:
for propValueTuples in [list(fileObj[1].properties.items()) for fileObj in list(file.objects.items())[1::]]:
propValueTuples
我正在使用 npTDMS Python 模块读取 TDMS 文件,但在获取所有通道属性时遇到问题。我可以使用 Scout 或 DIAdem 甚至内置的 LabVIEW 查看器打开我的 TDMS 文件,我可以看到文件中的每个通道(时间和压力)都有四个属性:NI_ArrayColumn、NI_ChannelLength、 NI_DataType,和姓名。但是,下面的代码只输出
OrderedDict([('NI_ArrayColumn', 1)])
代码如下:
from nptdms import TdmsFile
tdms_file = TdmsFile("2017-10-16;12.37.05_Pressure (1).tdms")
channel = tdms_file.object('Scan', 'Pressure')
print(str(channel.properties))
其他三个属性在哪里?
我发现 npTDMS
模块处理即时生成的属性的方式与内置 LabVIEW 查看器、Scout、DIAdem 和 Excel 添加的方式不同- 在做。这对我来说似乎是一个错误,所以我有一个 issue reported on the github。
我不知道以下代码片段是否回答了您的问题(也许错误已经得到纠正),但我发现 npTDMS 模块在检索动态生成的组属性时工作正常。
##Importing necessary packages.
import numpy as np
import nptdms
##Opening TDMS file.
file = nptdms.TdmsFile(my_file)
##Gets all file objects (group entities); each 'key/value' pair comprises a path and an object pointing to a group on the file.
fileObjs = list(file.objects.items())
##For each object (group), the written properties are retrieved and listed. The indexing is set to skip the root group.
for i in range(1, len(fileObjs)):
list(fileObjs[i][1].properties.items())
############################################################################
############################################################################
##Or, using list comprehension:
for propValueTuples in [list(fileObj[1].properties.items()) for fileObj in list(file.objects.items())[1::]]:
propValueTuples