LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to construct 2-D array out of TDMS file

Solved!
Go to solution

Hi,

 

I'm trying to make a 2-D array out of a Channel group in a TDMS file, so that I can view it similar to how Excel displays the file in a table format. I would then further process the elements of the 2-D array. I'm having trouble converting it into a table using the TDMS Read VI as I keep getting error -2532, cannot convert to specified format. I thought that treating the file as a 2-D array of strings would work but apparently it does not.

 

thanks,

Omar

0 Kudos
Message 1 of 10
(4,414 Views)

Can you show the code what you have tried?. Did you try using the TDMS file viewer vi?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 10
(4,413 Views)

Oh, here's what I have:

 

TDMSread.png

 

I want to take the output and process it further, thats my main goal. Viewing the data is just a debug tool for myself, so that's why I'm not using the TDMS file viewer.

 

thanks

Omar

0 Kudos
Message 3 of 10
(4,409 Views)

You need to read each channel by itself using the datatype that it was written to.  If you do this in a FOR loop and use autoindexing, you'll have a 2D array.  Of course, you will then need to convert to strings in order to put into a table.  Do you have a sample TDMS file for us to play with?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 10
(4,401 Views)

I do, I had to zip it to upload. it has 3 channel groups. I'll try out your suggestion

 

thanks,

Omar

 

 

0 Kudos
Message 5 of 10
(4,398 Views)

Are you sure that the data you are writing ino the file is a 2D string array?. Also try using the file viewer so that atleast you can confirm the data is present in the file.

-----

The best solution is the one you find it by yourself
Message 6 of 10
(4,394 Views)
Solution
Accepted by topic author Omar123

Ok, your culprit is the first channel (Time).  It is a timestamp while the other channels are doubles.  So you can follow this code in order to read all of the other channels into a 2D array.  You can convert to a string from there.  You can read the Time channel separately if you so desire.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 10
(4,390 Views)

Crossrulz, that works perfectly, thanks! I was expecting to also have the channel names in the table, is that also possible? I need the channel names because I am cross-checking the data with a "correct" value for each channel.  want to iterate through each channel and wanted to use the channel/column name as it contains the signal ID I need to compare. Is there a way to also have this in the array? Or to associate each column with the channel name somehow?

 

thanks,

Omar

0 Kudos
Message 8 of 10
(4,385 Views)

Actually, I think I've got it, I'll just use the array of channel names from the second read TDMS VI to get the index and use that to go to the correct position of the 2-D array.

 

thanks for the help guys 🙂

0 Kudos
Message 9 of 10
(4,377 Views)

Hello Omar,

 

I have looked at the attachment 2012.08.23_14.27.12_Data.tdms.zip ‏60 KB in your post, and I am really amazed by that. I am also doing some data grouping using TDMS in LabVIEW, and there will nearly 1000 channels, each keeping update its data per second. I was wondering whether you could send or post the block diagram you used to construct the attachment. I would really appreciate it since it will be extremely helpful to me.

 

Thanks a lot!

 

Sunming

0 Kudos
Message 10 of 10
(4,067 Views)