LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting TDMS files to LVM files using write to measurment vi

Hi all,

 

I am trying to convert tdms files into lvm files using 'read from measurement file' and 'write to measurement file' .

The problem i am currently facing is the tdms has a whole channel is in string, I am not able to take that out and write the string in to the comment in the lvm file.

It would be great if somebody give a hint on how to do that.

 

I have attached the vi that i have at the moment. 

I have searched arround in the forum, and got some code that provide in some posts, but those are not really working for me.

 

Thanks in advance.

Yifeng

0 Kudos
Message 1 of 3
(2,447 Views)

Hi,

 

There is no way to write a string array as a channel in 'write to measurement file'. The 'signals' item only takes dynamic data type and a string array cannot be converted to dynamic data. The 'Comment' item is not used for raw data. It cannot store a string array as you expect.

 

Since the channel stores timestamp in string format, you can firstly convert it back to timestamp, secondly convert it to double, then store the double array into lvm file.

 

Actually, what I'm curious about is what requirement makes you want to convert TDMS files to LVM files. TDMS is well supported. Maybe there are easier ways to meet your requirement by using TDMS directly.

 

Thanks,

zaizhou.ma

0 Kudos
Message 2 of 3
(2,428 Views)

As you have discovered, LVM files do not support arrays of strings.  Looking at your data, it appears the array of strings is timestamps for the arrays of data which follow.  I speculate you want this data as an X-column, followed by one or more columns of Y data.  I have to reiterate the previous question - why are you doing this?  Do you need LVM or will any text format do?  If any text format will do, your problem is relatively simple.  Read the data from the TDMS file, then write it to a text file using your own formatting.  This is fairly easy to do, and is easiest if you do not use Express VIs, for either the read or the write.  Express VIs are great, but only when they do what you want them to do.  If not, you need to do it yourself.  This is one of those cases.  If your TDMS files are not very large, you can do the following:

 

  1. Read all channels you want to write to the text file.  Hopefully, they are all the same length.
  2. Write a header for each column you want to write.  This is a string containing the name of each column with each name separated by a tab character.
  3. Loop through your data to generate each line.  The text data will not need to be reformatted.  Numeric data will need to be converted to strings (be careful to include enough significant digits).  Separate each value on each line with a tab character.
  4. Write each line to disk as you generate it.

This algorithm is straightforward, but inefficient.  If you have trouble with either memory size or time to execute, let us know.  There are ways to improve both memory use and speed of execution of this simple algorithm by orders of magnitude.

 

0 Kudos
Message 3 of 3
(2,406 Views)