Message Boards Message Boards

2
|
11951 Views
|
6 Replies
|
10 Total Likes
View groups...
Share
Share this post:

Corrupted Mathematica notebook

Posted 11 years ago
Hi,

a bunch of my notebooks got corrupted. These are not old, but actually I created them just today.

Please solve this problem quickly. I already tried the "open and parse the whole file" thing and purged my Mathematica settings such that I even had to reenter my License key.

I attached the corrupt file (well one of many that suddenly got corrupted). The code is fine but all text is broken.

Wait a second. I can't attach anything? How stupid is this forum? Dear Mathematica team then get in touch with your valued customer and tell me what to do / how to supply you with the file.

How ridiculous is that?

Thanks,

Dick
POSTED BY: Dick Seers
6 Replies
Here is a different notebook salvager than in the kb article Sean pointed to.
Neither is always better.  This is the one I start with.

With either of these methods, please make a copy of the damaged notebook file and operate on the copy.

Evaluate this cell to define the function.
 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[strm]-StringLength[result]];
 Quiet[cell=Check[Read[strm,Expression],tmpChar=" ";endPos=StreamPosition[strm];
 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[strm];]

Put the path to the corrupted notebook into the following function call.
Insert menu - File Path might be useful for finding the file and automatically
inserting it as the function argument.
RecreateNotebook[ ]
POSTED BY: Bruce Miller
There's a short article here on a utility built into Mathematica that can  help repair corrupted notebooks:
http://support.wolfram.com/kb/3300

F
rom my experience, it usually works. But if it doesn't, try contacting Wolfram technical support at support@wolfram.com with a copy of your notebooks and license number or activation key. 
POSTED BY: Sean Clarke
There's a lot here. I'm not a developer for the Front End of Mathematica or this forum, but I'll try to answer based on my best understanding.

If you are using Mathematica 8 or earlier, try using NotebookRestore[] instead of NotebookRestoreAT[].

The forum doesn't yet have every feature that we'd like it to. You can contact the developers of the forum through the pale blue Feedback button on the right hand side of the screen. 
Having the ability to upload files to this forum could be a major security issue for the forum  - it would allow people to upload malacious code. Most help websites similar to this one, such as stackexchange, do not have this feature probably for that very reason. Other people use DropBox accounts or other similar services and link to their files on those instead. 

We are aware that people want an improved undo function. It's much harder to implement than you would think at first, which is why you don't see it in the current version of Mathematica. This is because of the dynamic nature of Mathematica notebooks, homoiconicity, etc. 

It's hard to say why the notebooks become corrupted. Usually this is because something other than Mathematica edited them or because there was an issue while saving them.  I don't know of any issue regarding using Styles on text and the corruption of notebooks. 
POSTED BY: Sean Clarke
Posted 11 years ago
That was a very quick answer - thanks.

It doesn't help though. I had already tried this. The code you posts answers:

NotebookRestareAT[]

So it doesn't recognize it. It doesn't work.

What about my other remark: Why can't I upload a file to the forum?

Thirdly I had to notice that there still is not proper "Undo" - see here https://www.facebook.com/undoformathematica

Any movement on that front? That should not be too hard to achieve?

Dick
POSTED BY: Dick Seers
Posted 11 years ago
Weirdly, only text, but no code became corrupted. Seems to be something about the style. 

I always format as title, subtitle or subsubtitle (Alt + 1, 2 or 3).

Any ideas on that?
POSTED BY: Dick Seers
Posted 2 years ago
POSTED BY: Gary Palmer
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