npTDMS icon indicating copy to clipboard operation
npTDMS copied to clipboard

Preserve raw labview timestamps when defragmenting

Open jimkring opened this issue 1 year ago • 0 comments
trafficstars

Issue #200 added support for reading timestamps as raw TDMS timestamps. However, the TDMSWriter defragment function does not preserve this raw timestamp information when writing the defragmented file.

I tried to modify the defragment method by passing raw_timestamp=True to the TDMS reader, but that results in an error when writing back the file. Here’s that error:

File "defrag-py", line 31, in defragment new_file.write_ segment ([ChannelObject
File "venv\Lib\site-packages \nptdms \writer-py", line 149, in write segment segment. write(self._file)
File "venv\Lib\site-packages \nptdms writer-py", line 187, in write
metadata = self.metadata)
AAAAAAAAAAAAAAA
File "venv\Lib\site-packages \nptdms\writer-py", line 204, in metadata properties - read_ properties_dict(obj-properties)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv\Lib\site-packages \nptdms writer.py", line 358, in read_properties dict return OrderedDict(
AAAAAAAAAAAA
File "venv\Lib\site-packages \nptdms \writer.py", line 359, in ‹genexpr» (key, _to_tdms_value(val))
лАААААААААААААААААА
File "venv\Lib\site-packages \nptdms writer.py", line 382, in _to_tdms_value raise TypeError ("Unsupported property type for %™ % value)
TypeError: Unsupported property type for TdmsTimestamp(3779986269, 6576073492611989504)

jimkring avatar Jan 24 '24 00:01 jimkring