LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to recover my corrupted tdms file? 'RecoveryTDMSFile.vi' does not work for me.

Solved!
Go to solution

Hi,

I was collecting data using DAQmx and saving in tdms file.

After a while, I noticed that PC does not work (freeze) and I shut down using a physical power button.

 

When I opened my tdms file with 'TDMS file Viewer' in labview, it can see all data. However, when I use 'TDMS open', -2503 error occurred.

Also, I am using TDMS Reader function library in Matlab and it also 'Lead in' occurred error. (I think the last part of my data is corrupted.)

 

I searched this problem in NI forum and found 'RecoveryTDMSFile.vi', which is doing something on last segment in TDMS file. However, when I run this vi, I see

Not enough memory to complete this operation.' pop-up message. (I checked my memory using Task Manager in Windows and I have plenty of memory (18.4/31.9GB))

My tdms file is 2.76 GB.

 

Please refer the below screenshots. My tdms file consists of around 5928 groups. I definitely can sacrifice my last group, which is 'G5928'. Is there anyway that I can use this data?

Picture1.pngPicture2.pngPicture3.png

(If you compare G5927 and G5928 data, they are different. I guess G5928 is corrupted.)

 

0 Kudos
Message 1 of 5
(5,037 Views)
0 Kudos
Message 2 of 5
(5,048 Views)
Solution
Accepted by topic author Enhorse

First I'd suggest backing up your partially corrupt file.  I wouldn't want the data to be lost and then you to get mad at my suggestions which break it even more.  

 

On a copy of your partially corrupt file, open it in a hex editor like HxD.  Looking at the TDMS spec that you linked to it appears that every TDMS segment starts with "TDSm" so I'd go to the end of the file (CTRL+G, select end and hit OK).  Then do a search (CTRL+F) looking for Text-string of TDSm with the direction being Backwards.  This should find the last segment that was written.  Use Select Block (CTRL+E) then change the Length to 9999999999999999, just to make sure it will select all the way to the end of the file.  Click OK, then press the delete key.  Then go to File >> Save to save the changes which should be the deletion of the last segment.  This operation of selecting the last segment and deleting it should be possible with any hex editor, or LabVIEW VI if it is written right.

 

Now try to open the edited file and see if it works.  If it does I highly suggest you perform a defrag on your file.  I don't know what you are logging or how but I suspect the file is fragmented if you have that many groups and the file is that large.  If it doesn't open correctly do the same process as before deleting the last segment and try again.

Message 3 of 5
(3,513 Views)

Thank you!

I followed exactly your suggestion and it worked for me!

0 Kudos
Message 4 of 5
(3,478 Views)

Kudos.  I had the same problem and these exact instructions fixed the file for me.  In my case, it was the last TWO segments in the file that needed to be deleted.  Thanks!

http://www.medicollector.com
0 Kudos
Message 5 of 5
(2,528 Views)