问题描述
我正在使用 nptdms 模块在Python中打开* .tdms文件。这是我的简化代码:
from nptdms import TdmsFile
path = 'path_to_my_tdms_file'
tdms_file = TdmsFile.read(path)
Traceback (most recent call last):
File "<string>",line 1,in <module>
File "/.../lib/python3.8/site-packages/nptdms/tdms.py",line 136,in __init__
self._read_file(self._reader,read_Metadata_only)
File "/.../lib/python3.8/site-packages/nptdms/tdms.py",line 232,in _read_file
tdms_reader.read_Metadata()
File "/.../lib/python3.8/site-packages/nptdms/reader.py",line 85,in read_Metadata
segment = self._read_segment_Metadata(
File "/.../lib/python3.8/site-packages/nptdms/reader.py",line 234,in _read_segment_Metadata
segment.read_segment_objects(
File "/.../lib/python3.8/site-packages/nptdms/base_segment.py",in read_segment_objects
raw_data_index_header = _struct_unpack(endianness + 'L',raw_data_index_header_bytes)[0]
struct.error: unpack requires a buffer of 4 bytes
我还尝试使用 with 语句打开文件,如documentation所示:
with TdmsFile.open(path) as tdms_file:
...
但是我遇到同样的错误。
引发此错误的文件是否有可能被损坏,我如何确定呢?是否可以使用Python打开.tdms文件?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)