# Import large .txt MathML expression

I have extremely large .txt file (around 180 MB in the MathML form). This .txt file contains simplified expression in polynomial form and can not be reduced more. After starting the import process, after two days Mathematica 11 is still working. Is there any solution how to speed up it. Ram memory is 10% used all the time.

Large file is uploading long time (few days and nothing) MathML .txt:

https://www.dropbox.com/s/7ayc1i46bv24823/numerator.txt?dl=0

Small .txt with the same MathML structure is uploading fast (few swconds):

SetDirectory[NotebookDirectory[]];
imp = Import["num.txt"];
eq = ImportString[imp, "Expression"];

• Try "HeldExpression" or "InactiveExpression". Is it possible that any of the variables in the expression had values assigned to them when ImportString was run? This would cause Mathematica to substitute those values into the expression and then calculate to resolve eq. Depending on what they are this could take a while. Dec 1, 2016 at 11:25
• This is very hard to answer without knowing more details on what the file contains. One suggestion I have is using Streams to do a line by line read/write, as this can be more efficient that attempting to process all 180MB at a time (though of course this depends on the structure of the file) Dec 1, 2016 at 11:25
• Did you export the expression with Mathematica and was it fast to do so? Dec 1, 2016 at 11:32
• This takes less than 10 seconds: ToExpression[ ToString@Expand[(1 + x)^20000], InputForm, HoldComplete ]; // AbsoluteTiming. The data it produces is ~170 MB. As Edmund said, try str = Import["num.txt", "String"]; expr = ToExpression[str, InputForm, HoldComplete];. It can't be the parsing that's slow, it must be the evaluation. Your first Import should specify the format. Don't leave it to chance. Dec 1, 2016 at 11:36
• I did not write that .txt is in MathML form. Because of that Szabolic's suggestion does not work. I edited the question. Sorry because of forgotten information about .txt notation. Dec 1, 2016 at 13:07