skip to navigation
skip to content

cTDMS 0.91

Reading and writing TDM and TDMS files

############
Introduction
############

**cTDMS** is a Python package to read or write TDMS or TDM files.

TDMS or TDM are file formats developed by National Instruments and are the main file formats
for data storage in LabView from National Instruments.

**cTDMS** is using the NILIBDDC library from National Instruments, which is accessed by the help of the Python ``ctypes`` package.

Version 0.91 for 32bit and 64bit system


=============================
1. Reading TDMS or TDM files
=============================

To read a TDMS or TDM file you simply have to call: ::

from cTDMS.cTDMS import TDM_File

tdm=TDM_File("Data4.tdm")
tdm.open()

or: ::

from __future__ import with_statement
from cTDMS.cTDMS import TDM_File

with TDM_File("Data4.tdm") as tdm:
...
...
======================================
Accessing groups in a TDMS or TDM file
======================================

The tdm file object is organized like a dictionary. The groups contained in the TDM file can be acces by: ::

for groupname in tdm:
print "Group %s ------------"%( groupname)
group=tdm[groupname]

====================
Creating a new group
====================

A new group in the TDM file can be created with following command: ::

if "newgroupname" is not in tdm:
new_group=tdm.add_Group("newgroupname", "Description of the group")

Before creating a new group, it has to be checked, that this group is not already existing.

=========================
Getting data from a group
=========================

Measuring data are store in channels of a group. the can be easily accessed by getting the channels from the group: ::

for groupname in tdm:
print "Group %s ------------"%( groupname)
group=tdm[groupname]

for channelname in group:
print "Channel %s ------------"%(channelname)
channel=group[channelname]
print "Channel Properties -----"
for property in channel.attrs:
print property, channel.attrs[property]
# get some data
d=channel[5]
d=channel[-5]
d=channel[:]
d=channel[0:]
d=channel[10:-1]

t=type(d)
print "data type: %s, length: %d"%(str(type(d)), len(d))  
File Type Py Version Uploaded on Size
cTDMS-0.91.win32.exe (md5) MS Windows installer any 2014-03-25 296KB
cTDMS-0.91.zip (md5) Source 2014-03-25 104KB