I have ~150 student-submitted Mathematica notebooks for an assessed assignment. While I've been marking them, I'm suspecting there is a reasonable amount of plagiarism going on, when multiple students make the same odd errors throughout.
When I find something odd, I can use Notebook++ to search through all the notebooks for where it crops up elsewhere, but the .nb files have a lot of extra RowBox
and BoxData
etc.
I'm looking to convert just the input cells from each notebook into a text file, is there a way to do that programmatically?
The answer at: Converting a notebook to plain text programmatically shows how to automate the process of saving a single notebook as a text file, but I want just the "Input"
Cell
s and can't figure out how to do that.
Edit:
The answer from Alexey works generally, except when an integral has been input using the Integral sign on the palette. Running the code:
name = "test2.nb"
Export["test.txt", StringJoin[
Riffle[NotebookImport[name, "Input" -> "Text"],
"\n=================\n"]], "Text", CharacterEncoding -> "PrintableASCII"]
then makes something strange happen involving a SubsuperscriptBox
that I can't fix, which makes the output go over two columns, but within the text file: