MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to create a notebook outside of Mathematica?

  • To: mathgroup at
  • Subject: [mg114740] Re: How to create a notebook outside of Mathematica?
  • From: Albert Retey <awnl at>
  • Date: Tue, 14 Dec 2010 06:58:40 -0500 (EST)
  • References: <ie4msi$98t$>


> 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. 
I don't think it must be that complicated. If you need just InputForm
expressions separated in one cell each, this would be a prototype:

  Cell["(x+y)^1", "Input"],
  Cell["(x+y)^2", "Input"],
  Cell["(x+y)^3", "Input"]

I think this should not be too difficult to generate also from other



  • Prev by Date: Re: Integral no longer evaluated in Version 7, 8
  • Next by Date: Re: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in denominator
  • Previous by thread: How to create a notebook outside of Mathematica?
  • Next by thread: Re: How to create a notebook outside of Mathematica?