Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 188

Coverting .nb file code content to string type using NotebookImport

$
0
0

For my work I need to import the notebook and get all the contents from the code cell. For this task I chose ToString/@NotebookImport[file,"Input"->"HoldExpression"].

"Input"->"HoldExpression" is very useful combination because it converts all the code into a single view, converting some infix function notations into a single view.

There is one problem: division and exponentiation operations produce incorrect results.

Example below:input notebook code cells content:

Total[m]/na^2/3Flatten@{a}

output strings:

{"             Total[m]\\nHoldComplete[--------]\\n                \n", "              2\n             a\nHoldComplete[--]\n             \3", "HoldComplete[Flatten[{a}]]"}

How can I solve this problem while maintaining all functionality?


Viewing all articles
Browse latest Browse all 188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>