[Date Index] [Thread Index] [Author Index]
How to create a notebook outside of Mathematica?
I often would like to be able to use some external program (e.g. a Python script) to generate the input expressions for a Mathematica notebook. The problem is that I don't know how best to turn such a file of Mathematica expressions into something that Mathematica will recognize as a notebook. One naive approach would be to tack the extension .nb to such a file, and open the file with Mathematica, but this doesn't work too well. Mathematica *will* open such a file without any fuss, but it stuffs all the expressions into a single cell. As a result, evaluating such a notebook produces a huge, unreadable heap of output right after the bloated single input cell. Is there a better way to do this, so that I don't end up with all the expressions in a single cell? For example, is there an easy way to tell Mathematica to treat expressions separated by at least 2 newlines as belonging to different cells? Alternatively, is there a way to automate the splitting of the single cell into multiple ones? TIA! ~kj P.S. I realize that regular notebooks generated by Mathematica are just text files, describing cells, etc., as Mathematica expressions, and, of course, I could just write *that* out, i.e. not just the expressions I'm interested in, but also the surrounding cell specifications. This is way beyond my grasp of Mathematica's internal notebook format, and this is an area in which the documentation is *particularly* cryptic, so I prefer not to go anywhere near such a solution.