Concatenat​ing TDMS Files

Hello,
I'm writing a script in DIAdem 2011 which combines data from multiple sources into a single TDMS-File. Exporting into multiple TDMS files works fine( I can open them in DIAdem) but I'm having trouble combining all files to one TDMS-File. Speed is important, so I tried to avoid loading all data into the dataportal and saving again (this works though).
If I understood correctly it is possibly to directly concatenate the binary contents of the files into a single file. Is this correct? Because using the MS-Dos copy command or using a VBS-Script in DIAdem with Stream-Objects both results in TDMS-Files that I can't open anymore.
The error message says:
"TDS Exception in Intialize: Tds Error: TdsErrNotSupported(53):"
It seems only one of the files produces these problems. When I load this one file and save it again as TDMS I can sucessfully combine them and load the resulting TDMS without errors.
Perhaps the file is fragmented and this leads to the error (the offending file is measurement data)? Is this expected behaviour for fragmented files?
How can i efficiently combine these files? I have to be able to combine multiple hundreds of files ( in pairs. e.g. combine 400 TDMS in pairs to 200 TDMS files) fast and i guess opening 200 files, saving again and combining is rather slow.
Is there an efficient way to solve this task?
As the offending file is actually TDMS-Data from a BLOB-Datafield in a SQL-database another solution might be loading the TDMS directly from the database into the dataportal and saving from DIAdem, instead of dumping the BLOB-data into a TDMS-File on the HDD( i guess this results in a defragmented file as opening and saving resolves the problems).
But I'm not sure how to achieve this. I'm using ADO to interface with the SQL-DB. The code looks approximately like this:
Set recordSet = CreateObject("ADODB.Recordset")
recordSet.Source = 'QUERY
recordSet.open
Set fso = CreateObject("Scripting.FileSystemObject")
'Create Stream object
Set BinaryStream = CreateObject("ADODB.Stream")
do
chunkSize=100
lngOffset=0
lngFileSize=recordSet.Fields.Item("Field").ActualS​ize
'Open the stream And write binary data To the object
BinaryStream.Open
do while lngOffset<lngFileSize
varChunk=RecordSet.Fields.Item("TDMS_DataInBLOB").​GetChunk(chunkSize)
Call BinaryStream.Write(varChunk)
lngOffset=lngOffset+chunkSize
loop
'Save binary data To disk
Call BinaryStream.SaveToFile("path", adSaveCreateOverWrite)
BinaryStream.Close
Call RecordSet.MoveNext
loop until RecordSet.EOF
 How can I change this code to write the data into the dataportal?
Thanks in adavance.
Best regards,
grmume

Hi Brad Turpin,
I have already tried concatenating the files with the copy command. I don't have a hex-editor at work but by looking at the filesizes and checking the contents with a texteditor the script seems to work but I can't open the created file.
The script I used looks like this:
private Sub mergeFiles(filePath1,filePath2,outFilePath,bDelete​Input)
if bDeleteInput then
Call ExtProgram("cmd.exe","/Q /c copy /b """&filePath1&""" + """&filePath2&""" /b """&outFilePath&""" &del """&filePath1&"""&del """&filePath2&"""")
else
Call ExtProgram("cmd.exe","/Q /c copy /b """&filePath1&""" + """&filePath2&""" /b """&outFilePath&"""")
end if
End Sub
 To test your script I defined the following variables:
NewFileName="C:\Documents and Settings\username\Desktop\new folder\combined.TDMS"
ChanNames(0)="file1"
ChanNames(1)="file2"
Folder="C:\Documents and Settings\username\Desktop\new folder"
DosDrv="C:\Documents and Settings\username\Desktop\BatchFile"
 It completed sucessfully but the result is the same. I can open the two seperate files(file1.tdms and file2.tdms) but I cannot open the combined.tdms.
Sadly I can't share the original files and I can't use DIAdem to fill the files with dummydata because opening in DIAdem and saving resolves the problems.
Do you have an idea what causes these problems? The possibility to combine tdms-files like that was a big bonus for me...
Can I somehow fill the files with dummydata without opening them in DIAdem? Or tell DIAdem to keep the original file structure but change the values?
Best regards,
grmume

Similar Messages

  • How to concatenate TDM files in DiaDem

    I've seen the post on how to concatenate CSV files on DiaDem ... but how do you concatenate TDM files together?
    I'm surprised this functionality isn't embedded into the software as it is a fairly common task, and the script is likely beyond most user's ability to maintain.
    Solved!
    Go to Solution.

    Hi Brad,
    Maybe I didnt explain myself that well, my fault. The case is:
     As a result of acquired data post analysis with LabVIEW, I am logging into TDMS files 1.7GB of data. It's a file of 15 columns (properties) each of 1,080,000 rows ( properties values).
    If I decide saving all the data into one file ( resulting into a 1.7GB file), DIAdem cannot load it into Data Portal. The program gets frozen even after waiting for 30mins.
    If I save the data into multiple files (i.e like I tried last time in 3 files of around 500MB and one around 270MB) the 3 first files are loaded into data portal but when the loading of the 270MB is under way, DIAdem gives me an indexing error (sorry cant recall right now what is says exactly).
    In the case of saving into multiple files, apparently I want to concatenate the TDMS file channels so I can i.e graph plots for the whole duration of my test.  A reappending VBScipt you kindly provided me, works fine with any file I used that was not as massive as the ones I am dealing now. When I am using it with the above mentioned files, in the end I just get a time channel and none of the channels in my TDMS files.  
    Using a VBScipt that requires that I load my data into Data Portal before running it, it's simply impossible as DIAdem stalls as I mentioned above.
    Sorry, I havent been using scipting before so I might be missing something here. As it goes for those changes you suggested. i will give it a  try but could you please confirm which scipt we are talking about now exactly? As for concatenate files, the code Herbert provided in that thread is great but it does nor address exactly my problem.
    Thanks,
    Panos
    Message Edited by Saloutios on 06-14-2010 04:27 AM

  • Read multiple tdms files

    Two questions:
    1) how can i rename the different signals in the tdms file? Now they are names "untitled x". I am looking for an elegant solution, because i record about 200 different Signals.
    2) Is there an "easy way"  to select, read and concatenate multiple TDMS files to show them in a graph?

    I had a similar goal with grouping plots and  rearranging them on the X-axis, so I put together this pretty quickly to search a range of TDMS files for a specific channel, should be able to adapt it pretty easy to suit your needs, once you manage to rename your channels.
    Attachments:
    Record Grouping.vi ‏48 KB

  • How to read TDMS file use DDC_GetDat​aValuesStr​ing in C language.

    1. Below code is correct, because the numDataValues is one, machine=sibot
    char ss[10]={0};
        char *strMachine=new char[1];
        *strMachine=ss[10];
        nullChk (strMachine = (char *) malloc (sizeof (char) * (unsigned int)numDataValues));
        ddcChk (DDC_GetDataValuesString (channels[i], 0, (unsigned int)numDataValues, &strMachine));
        printf ("Channel value for Machine : %s\n", strMachine);
    ---then show "nel value for Machine : sibot"
    2. But when the numDataValues is more one, I can't get all the data in the TDMS file, only can get the first one.
    eg:
    data one is FI,
    data two is O
    but I only can get FI....
    what's wrong?? How to solve it?? The data format as attachment.
    Attachments:
    20131110151804.jpg ‏11 KB

    Hi KittyDeng,
    I guess the problem is from here:
    char *strMachine=new char[1];
    You allocated a char array of only 1 element which will not hold as many chars.
    The best way to solve the problem is to allocate more memory than that of the data, where in your case, you can write:
    char *strMachine=new char[20];//or set more than 20
    Hope this helps.
    Zhiqiang Tu
    NISH AE

  • TDMS File Creates Multiple Tabs of Data. Want to create only one.

    Hello NI Community,
    I am currently using the DAQ Assistant with my string pots to record displacement over a long interval of time (see attached VI). I am then using the "Write To Measurement File" vi to save the data into a TDMS file (see the "Write to File Settings" picture attached for all settings chosen for file write). The file is being written, however when I open the TDMS file, the document creates a tab in Excel for every second of data recorded (please see the attached "). It looks like the TDMS file is grouping all the data from each second together and then creating a new group of data.
    How do I get the file to write all the data onto a single tab instead of creating multiple? I do not want to have to concatenate hundreds of tabs into a single excel sheet.
    Thanks,
    Chris
    Solved!
    Go to Solution.
    Attachments:
    Write to File Settings.PNG ‏40 KB
    TDMS File Multiple Tabs.PNG ‏57 KB
    TDMSWrite.vi ‏108 KB

    You should not be using the comment.  I just removed that and it all worked for me.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Signal Express Large TDMS File Recording Error

    Hello,
    I have the following application and I am looking for some tips on the best way to approach the problem with Signal Express:
    I am attempting to using Signal Express 2009 (Sound and Vibration Assistant) to collect random vibration data on three channels over an extended period of time -- about 20 hours total.  My sample rate is 2kHz.  Sampling at that rate over that period of time invovles the creation of a very large TDMS file, which is intended for various types of analysis in signal express later or some other application later on.  One of the analysis functions to be done is a PSD (Power Spectral Density) plot to determine the vibration levels distributed over a band of frequencies during the log. 
    My original solution was to collect a single large TDMS file.  I did this with Signal Express recording options configured to save and restart "in current log" after 1 hour worth of data is collected.  I configured it this way because if there is a crash/sudden loss of power during data collection, I wanted to ensure that only up to an hours worth of data would be lost.  I tested this option and the integrity of the file after a crash by killing the SignalExpress process in the middle of recording the large TDMS file (after a few save log file conditions had been met).  Unfortunately, when I restart signal express and try to load the log file data in playback mode an error indicating "TDMS Data Corrupt" (or similiar) is displayed.  My TDMS file is large, so it obviously contains some data; however, Signal Express does not index its time and I can not view the data within the file.  The .tdms_index file is also present but the meta data.txt file is not generated.  Is there any way to insure that I will have at least partially valid data that can be processed from a single TDMS file in the event of a crash during mid-logging?   I don't have too much experience dealing with random vibration data, so are there any tips for generating vibration level PSD curves for large files over such a long time length?
    My solution to this problem thusfar has been to log the data to seperate .TDMS files, about an hour in length each.  This should result in about 20 files in my final application.  Since I want to take a PSD, which ends up being a statistical average over the whole time period. I plan on generating a curve for each of these files and averaging all 20 of them together to get the overall vibration PSD curve for the 20 hour time period.

    JMat,
    Based on the description of your application, I would recommend writing the data to a "new log" every hour (or more often). Based on some of my testing, if you use "current log" and S&V Assistant crashes, the entire TDMS file will be corrupted. This seems consistent with what you're seeing.
    It would be good if you could clarify why you're hoping to use "current log" instead of "new log". I'll assume an answer so I can provide a few more details in this response. I assume it's because you want to be able to perform the PSD over the entire logged file (all 20 hours). And the easiest way to do that is if all 20 hours are recorded in a continuous file. If this is the case, then we can still help you accomplish the desired outcome, but also ensure that you don't lose data if the system crashes at some point during the monitoring.
    If you use "new log" for your logging configuration, you'll end up having 20 TDMS files when the run is complete. If the system crashes, any files that are already done writing will not be corrupted (I tested this). All you need to do is concatenate the files to make a single one. If this would work for you, we can talk about various solutions we can provide to accomplish this task. Let me know.
    Now there is one thing I want to bring to your attention about logging multiple files from SignalExpress, whether you use "current log' or "new log". The Windows OS is not deterministic. Meaning that it cannot guarantee how long it takes for an operation to complete. For your particular application, this basically means that between log files there will be some short gap in time that the data is not being saved to disk. Based on my testing, it looks like this time could be between 1-3 seconds. This time depends heavily on how many other applications Windows has running at the same time.
    So when you concatenate the signals, you can choose to concatenate them "absolutely", meaning there will be a 1-3 second gap between the different waveforms recorded. Or you can concatenate them to assume there is no time gap between logs, resulting in a pseudo-continuous waveform (it looks continuous to you and the analysis routine).
    If neither of these options are suitable, let me know.
    Thanks, Jared 

  • Error reading TDMS file with inconsiste​nd dt

    Hello all,
    I would like to ask your help to understand how to read a TDMS file which I am opening and closing based on a user input.  As a result the data in the TDMS file does not have a consistent time step, which may be causing my problem, but I really don't know.  I keep getting the error 2501, that I have an invalid reference. 
    Or, if I continue and bypass the error, the extract portion VI gives me an error stating that I need to define an integer multiple of dt.
    I am not sure how to solve the first point as I have the reference wired directly to the read TDMS vi.
    I have attached a screen shot of the error and the portion of the VI with the offending error (it is the code connected to the read TDMS read vi).
    My goad is to extract a portion of the data to do calculations on and display a result to the user.
    thanks for any comments.
    A. Lopez
    Attachments:
    error-2501.JPG ‏198 KB

    I think you open multiple times the same TDMS file, you should open it before the while loop. And I don't see a close tdms function...
    Also check for errors on the open TDMS function.
    Ton
    Message Edited by TonP on 02-14-2007 07:45 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How can I open a tdms file and replace a subset of data then save that change without re-writing the entire file again?

    Hi all,
    Is it possible to open a tdms file and make a small change an an array subset then save the file without having to save the whole dataset as a different file with a new name? That is to say, is there something similar to "Save" in MS Word rather than "Save As"... I only want to change a 1D array of four data points in a file of 7M data points.
    I am not sure if this make sense? Any help is apreciated.
    Thanks,
    Jack

    You can use either one, but for your application, I would use the synchronous.  It requires far less setup.  When you open the file, set both enable asynchronous and disable buffering to FALSE to enable you to use synchronous with arbitrary data sizes.
    Attached code is LabVIEW 2011.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    UpdateTDMS.zip ‏20 KB

  • How to get the last data point from a TDM file in LabVIEW?

    Hello,
    I am using LabVIEW to analyze some rather large TDM files, and I need a way to get only the last data point.  So far, the only way I have been able to accomplish this is by reading the entire file.  Is there a property in the TDM file or a function in LabVIEW that will allow me to get the index of the last item in a channel?  
    Thanks!
    Christina

    Do you want to avoid reading whole file and want to be able to reach or get the index of last value of channel? is there any specific reason? I am not sure you could do it without loading the whole file. But the easiest way would be just to use array functions "array size" would give you the index of last element. 
    -Nilesh
    Kudos are (always) welcome for the good post. :-)

  • Newly written tdm/tdms file not found

    Hi,
    I am trying to save some simple thermocouple data to a tdm/tdms file.  I run my vi and it seems to work just fine. I am using the NI 9213 getting started example as a basis and have added tdms open, tdms set properties, tdms write, and tdms close.  I can see the data streaming on the waveform chart but when I hit stop and go look for the saved file I can't seem to find it.  What am I doing wrong?
    Thank you
    Solved!
    Go to Solution.

    SRamirez wrote:
    I set it to create.  When I run it once for a new folder it runs just fine but if I try again I get error 6.
    You are specifying a folder?  You should be giving a full file path (like c:\temp\blah.tdms).  What you might want to do is build a file name based on the data/time.  This way you won't have to worry about overwriting files and what not.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Build File Name.png ‏9 KB

  • How to compare signals from two different .tdms files?

    i'm developing a lie detection system in labview.so inorder for that i need to compare the threshold physiological signals from the .tdms file with the signals i acquire continuelsy from the subject for each question asked.i use respiration monitor and heart beat monitor together with the sensorDAQ to acuire the physiological signals.so which are the function i should make use of?i have the following toolkits
    1. advanced signal processing toolkit
    2. adaptive filter toolkit
    3. digital filter design toolkit
    4. biomedical toolkit
    please give me advise on this.
    thank you.
    Solved!
    Go to Solution.

    Lie detector systems (polygraphs) generally work by looking at the physiological responses to the own subjects baseline, and do this in real-time.  You could use a file that represents the stored "baseline" for the subject, but the overall environment, circumstances, general state of the subject, etc. may not be similar enough to easily see subtle changes.
    From the stored file, you might determine a set of parameters or thresholds that indicate "normal, relaxed" for each signal.  You could read the file into your LabVIEW program, process each channel, and save these parameters.  Then when you have the new data, you can read the new data file in and process it in a similar way and then determine whether the parameters are outside the limits that you established for a "lie".
    You may get more responses to this question if posted in the Biomedical User Group
    Visit the NI Biomedical User Group at:
    www.ni.com/biomedusers

  • How do I select more then one channel to view in tdms file viewer graph panel

    I have a TDMS file that I can view with the labview 2013 TDMS file viewer and I can select one signal out of 15 signals to view on the graph panel. however I would like be able to look at 2 or 3 signals
    on the same graph but can't seem to be able to select more then one signal at a time. Is there a way to select more then one to view?  

    I've modified the TDMS viewer in the past to allow selecting multple channels.  It's a little bit of a pain because the tree control in the viewer only allows you to select one item.  You have to edit the tree to allow multiple items.  Now your selection is an array instead of a scalar.  This means the rest of the code has to be updated, and the references to the tree in subVIs need to be updated.  Not impossible but it takes some time.  Alternativly open it in Excel with the free add-in then you can select the two columns you want and insert a graph.  Not as simple for the user but using Excel, which users should be familiar with might mean users need less training on data files.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How does DIADEM import TDMS files? How gets every channel his number and groupindex? How can I determine which channel has which groupindex and number?

    I store different channels in a TDMS file.
    I like to have a time channel at the first position with group index 1 and number 1.
    When I read the TDMS file with DIADEM the time channel (Float64) is on a differernt position, and the channels are not sorted alphabetically.
    Here are my questions:
    How does DIADEM import TDMS files?
    How gets every channel his number and groupindex?
    How can I determine which channel has which groupindex and number?
    Best regards
    Joerg

    Hi Jörg,
    i suppose that you´re programme whose create the *.tdms file is writing on false position. Try to create datas with timechannel on first indes in diadem, then save it and then open it again. you see that all is correct. So please tell me what programm in what version do you use and please attache it here.
    Did you use the library for creating *.tdms files like in the link ?
    http://zone.ni.com/devzone/cda/tut/p/id/6471
    Here you find the gtdms_8.x.zip - when you extract it and opened the *.llb you find vi´s for all functions e.g. writing 2d array of strings to *.tdms file
    when you open the subvi´s then you see how created and writing datas/structure to *.tdms files. Because *.tdms is binary you can´t see structure with open it in editor.
    When you don´t have Labview you can use the 30 days test of current version 8.5 under following link
    german version download link
    https://lumen.ni.com/nicif/d/lveval/content.xhtml
    english version download link
    https://lumen.ni.com/nicif/us/lveval/content.xhtml
    Hope it helps
    Best Regards

  • .tdm file storage vi's slow editing vi's

    I am developing software using Labview 8.5 and have recently added some file storage vi's for the .tdm format for use in DIAdem 10.2.  Upon using the open storage, set file properties, write channel group, write channel, and close storage vi's, the editing has become extremely slow - for any operation I try to perform there is a 10-15seconds delay before it occurs.  If I remove the .tdm vi's from my diagram then the editing goes back to normal and changes/operations occur almost instantaneously as expected.  My project is not large as far as I am concerned (Front panel - 121k, block diagram=1538k, code=0.2k, data=957k, total=2617k, total vi size on disk=389k)
    I saw a similar post to the .tdm storage vi's causing this to occur back in 2005 and was supposed to have  been on the fix list but it does not appear that it has 3 years later.  I am sure many others are using these vi's so not sure what I may have done differently to cause the editing to slow down so much.  
    Anyone with ideas and fix would be greatly appreciated as I cannot afford to sit around 10-15 seconds for every step of my developement.

    Yes, sometimes Storage VIs are slow. But They are Express VIs, supplying the easy configuration for users. If you feel they are too slow, I suggest that you can use TDMS files instead.

  • Tdms-files: Is it possible to prevent LabVIEW and DIAdem from creating .tdms_index files?

    Hello,
    is it possible to prevent LabVIEW and DIAdem from creating .tdms_index files when opening/creating/editing a .tdms file?
    I think I have no benefit from the .tdms_index files because our applications create a lot of little .tdms-files (repeat measurements). With the additional .tdms_index files we have unnecessary memory consumption and it takes longer for Windows to open the containing folder. Also it´s confusing when searching for a certain file.
    Best Regards
    Daniel
    Solved!
    Go to Solution.

    Hi Baui,
    I'm afraid there's a direct way to disable creating .tdms_index file now from LabVIEW and DIAdem. You can use TDMS Advacend API in LabVIEW, which doesn't create any index file, or you can just make some simple programming and delete the .tdms_index file after closing the TDMS file. 
    This is a request for a long time, we'll consider to add this feature for TDMS in future releases.
    Yongqing Ye
    NI R&D

Maybe you are looking for

  • Purchase order to pdf conertion

    Hi,   I am working on 4.7 version. I need to generate pdf file for po fom. My senario is when i am executing in me9f in back ground at the end of the day it should genarate po forms in pdf files in application server.

  • Editable Form crashes

    I have Acrobat 9 Pro Extended and Windows 7. Trying to create an editable form. I use the Wizard, save it, close editing, distribute form as a hard copy for later emailing. It errors with no error code. Please help. Thank you so much.

  • JTextField Question

    Hey guys, I've google'd all over the place and I'm still not getting what I want, hopefully you can help. :) I'm trying to use a gui for class assignment to make it a little more flashy. The first thing I'm trying to do before I even start coding is

  • Qry with non aggregate cols and not in group by clause too.

    Hi all, This is the table. PROFILE_ID_NO WORK_OK_CD CREATE_DT 7041086 Y 2003-10-07-10.56.42 7041086 Y 2003-10-05-10.56.42 7041086 null 2003-10-06-06.58.08 7041086 N 2004-09-30-05.08.22 I want a qry to pick a profile_id_no and work_ok_cd where create_

  • I am not able to access facebook even though I have downloaded the app

    On my computer, the app is there, but on my ipod, it isn't.  When I access the apps store, it says it is installed but it is not on my ipod.