New answers tagged

2

Here is a solution written in the spirit of the answer by george2079 but NOT relying upon the buggy NBImport.exe executable. Instead it uses FrontEnd for converting Notebooks into plain text using the findings described here: findInNBFile::cntconv = "Failed to extract plain text from `1`"; findInNBFile[NBFilePath_String, stringPattern_, resPerFile_Integer: ...


2

A couple of additional solutions. The first, with FindList, is probably the simplest and quickest. Using FindList searchDir = "<NB dir>"; fnames = FileNames["*.nb", searchDir, 2]; Length@fnames sres = {#, FindList[#, {"curve"}, WordSearch -> False]} & /@ fnames; sres = Select[sres, Length[#[[2]]] > 0 &]; Grid[sres, Dividers -> All, ...


4

Here is an approach which does not rely on the NBImport.exe (which actually performs importing of the NB files as "Plaintext" under the hood) and performs all the operations in the Kernel only. Currently NBImport.exe contains a bug due to which it returns $Failed when have to import a NB file with non-ASCII file path. I'm also not sure how it interprets ...


7

Here is a way to search from within mathematica: notebooks = Quiet@FileNames["*.nb", NotebookDirectory[], 2]; Monitor[Select[ Table[{nb, StringJoin@Select[ StringSplit[Import[nb, "Plaintext"], "\n"] , ((If[#, Print["match on:", nb]]; #) &@ StringMatchQ[#, "*NIntegrate*"]) &, 5]}, {nb,notebooks}], #[[2]] ...


2

As explained in the comments above, the problem is that Import["pd.dat"] does not correctly interpret the exported text file. You can see this by evaluating gigi[a, b, c, d, e, f] which returns {{4, "+", "Log[a]"}}. Since the file "pd.dat" contains only "4 + Log[a]", this gets interpreted as the number 4, followed by a "+" sign, followed by the string ...



Top 50 recent answers are included