Thread: Reading specific data from TDMS files

  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    6

    Reading specific data from TDMS files

    Hello

    I am trying to build a function that can read specific data that I want from different TDMS files.

    I have read all of the technical format information on the NI website and even gone through a TDMS file byte after byte using a binary code reader(hex workshop) to understand the structure and what every part means.

    I figured out I should read the file as a binary file ofcourse, but what I haven't figured out is how do I get to the specific data I want?
    for example, I want the content of a property called 'wf_start_time'.
    I don't understand how to navigate through the binary file using bitwise operators, since the structure of TDMS files changes from one file to another due to different object or properties they contain. If in one file this property is stored in the 20th byte from the start, in another file it may be stored in a different place.

    Any suggestions please?

    Thanks!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,983
    TDMS File Format Internal Structure - National Instruments
    Well you need to figure out how to parse the file from the beginning.

    From the look of things, you have various kinds of data arranged in blocks. Some blocks are fixed in length and/or number, and others are variable.

    Blocks which are variable length have a 'length' stored within them.

    1. Logical Structure
    TDMS files organize data in a three-level hierarchy of objects. The top level is comprised of a single object that holds file-specific information like author or title. Each file can contain an unlimited number of groups, and each group can contain an unlimited number of channels. In the following illustration, the file example events.tdms contains two groups, each of which contains two channels.
    As an exercise, write a program which just dumps the group/channel hierarchy to your console.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2016
    Posts
    6
    I made it
    I wrote a function that finds the exact value I need by the name of the string. since before each string there is a 4-byte value with the size of the string, I found the first character of the string, jumped(fseek) 5 bytes back, read the value, then the string using the length, then verifying the string name with strcmp().
    I was trying to avoid reading all the objects or properties of the file.
    Thank you though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help - Output specific data from 2 txt files
    By plat in forum C++ Programming
    Replies: 1
    Last Post: 10-12-2012, 07:36 PM
  2. Specific data extraction from .txt files using fstream.h
    By xScen3xHdstyl3x in forum C++ Programming
    Replies: 4
    Last Post: 10-28-2011, 01:58 AM
  3. Reading data from files
    By heinrichxs in forum C++ Programming
    Replies: 3
    Last Post: 02-07-2011, 01:13 PM
  4. reading data fom files
    By shuo in forum C++ Programming
    Replies: 11
    Last Post: 10-22-2007, 12:24 AM
  5. Help Reading Data from Specific Filenames
    By RguyK128 in forum C Programming
    Replies: 4
    Last Post: 02-18-2005, 06:26 AM

Tags for this Thread