Message Boards Message Boards

6 Replies
10 Total Likes
View groups...
Share this post:

Corrupted Mathematica notebook

Posted 10 years ago

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?


POSTED BY: Dick Seers
6 Replies
Posted 2 years ago

I can see Bruce's code as potentially useful, and thank him for that. After 8 years, the link in Sean's post is broken. Is Bruce's code still valid for version 11.6?

I suspect that many, such as myself use Mathematica because it is a high level notation that enables one to write code pertaining to things like language, geography, or mathematics. We want a system that runs smoothly and doesn't require us to get our hands dirty with even mid-level code for the operating system and file paths. Granted that Mathematica notebooks are complex and probably hard for the front end programmers to get just right, but a restore function should at least work within the notebook being restored. One should not have to create a separate notebook to define the restore function and then figure out a file path and run it, though I see that one could probably avoid that by putting the restore function in the same folder with the corrupted file. Even better, Restore could be a menu choice.

I write this as one who often encounters corrupted files that display poorly as .pdf files. This happens less often when I use only the default font in the default size, but I still have problems in version 11.6, especially with squares and square roots in Text cells, and quotients often break down into linear text with slashes for the quotient divider. Perhaps Mathematica should automatically run a restore function before every save or print to .pdf.

POSTED BY: Gary Palmer
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.
 Quiet[cell=Check[Read[strm,Expression],tmpChar=" ";endPos=StreamPosition[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 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 10 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 10 years ago
That was a very quick answer - thanks.

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


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

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

POSTED BY: Dick Seers
There's a short article here on a utility built into Mathematica that can  help repair corrupted notebooks:

rom my experience, it usually works. But if it doesn't, try contacting Wolfram technical support at with a copy of your notebooks 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
or Discard

Group Abstract Group Abstract