Message Boards Message Boards

0
|
19475 Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

File corrupted

Posted 11 years ago
 I had a very important file corrupted. Please can someone help me. I'm Mathematica User many years and never had this problem. And now happened to a very important file. I am sending the attached file, you guys can fix it?
Attachments:
POSTED BY: Cleuzir da Luz
5 Replies

I might be a little late, but I decided to take a look at the file.

All Mathematica notebooks are actually stored in a (semi) human-readable symbolic form, represented by a nested set of Cell[] objects. When one knows where the error is, one can manually repair a corrupted notebook.

Mathematica reported the error as being in the last cell group. I wasn't able to find its exact origin, so I had to delete the group. Then an error was reported in some form of cache information at the bottom of the file, stored in comments. My guess is that it has something to do with undo history or clipboard storage. I deleted that as well, as it shouldn't be essential to the operation of the notebook.

That was enough to get the notebook open, but at the bottom of your content there was an oddly large large string of text starting with a U, probably a remnant of the corruption.

Large remnant.

Below that there was a set of text cells containing the actual raw contents of the file. I have absolutely no idea why Mathematica loaded the file in this way, but I deleted them.

Finally, the file was rid of corruption. Hopefully it's still useful!

Attachments:
POSTED BY: Jesse Friedman

Slightly relates as it has to do with keeping backups of your work, and there have been several discussion recently about corruption and backups, take a look at this tool that I recently posted on: http://community.wolfram.com/groups/-/m/t/320808

POSTED BY: David Reiss

The link: http://support.wolfram.com/kb/3300 appears to be out of date as there is no *RestoreNotebookAT[]function in AuthorTools in Mathematica 10. There is a RestoreNotebook[] function.

It appears my notebook and backup of my notebook on a separate drive are too far gone to benefit from the code for RecreateNotebook above.

POSTED BY: Doug Kimzey
Tech Support recommends making a copy of the damaged file and working with the copy.

The second method Sean shows is the newer and usually (but not always) better code for this.
POSTED BY: Bruce Miller
Please see this article on repairing corrupted notebooks. 

http://support.wolfram.com/kb/3300

If this doesn't work try to evaluate the following code:
 RecreateNotebook[fileName_String]:=      
 Module[{nb=NotebookCreate[],strm=OpenRead[fileName,BinaryFormat->True],result,cell,tmpChar,beginPos,endPos},
 While[(result=Find[strm,{"Cell[\"","Cell[BoxData[","Cell[TextData["}])=!=EndOfFile,    
 beginPos=SetStreamPosition[strm,StreamPosition-StringLength[result]];
 Quiet[cell=Check[Read[strm,Expression],tmpChar=" ";endPos=StreamPosition;
 While[tmpChar=!=","&&endPos>beginPos+1,SetStreamPosition[strm,--endPos];
 tmpChar=Read[strm,Character]]; If[endPos>beginPos,SetStreamPosition[strm,beginPos];
 ToExpression@StringJoin@ReadList[strm,Character,endPos-beginPos],$Failed]]];
 If[Head[cell]===Cell,NotebookWrite[nb,cell,After]];];Close;]

Then run the function RecreateNotebook on the file path to the corrupted file. 
You can use Insert > FilePath... to insert the file path into the notebook. 

If you still see any issues, contact Wolfram Technical Support at support@wolfram.com with your name and license number or activation key. 
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract