Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I attempted to import a very short .txt file string using the Import command:

Import["C:\\TestFile.txt"] // AbsoluteTiming

Out: {0.020001, "Test"}

Why does this take 20 milliseconds? Export is about an order of magnitude faster for the same string:

Import["C:\\TestFile.txt","Test"] // AbsoluteTiming

Out: {0.002000, "C:\\test.txt"}

Are there any hidden options for Import like the following (concerning TIF files) from a previous question of mine Slow import of multigigabyte TIF image stacks?:

Image`ImportExportDump`ImageReadTIFF

Quoting the user cormullion from my previous question: "For the OP's single frame, it's 0.015 for Import, but 0.000745 for ImageReadTIFF on Mac/M9. That might be worth having."

share|improve this question
1  
Import comes with a lot of overhead. Try for example Import["testfile.txt", "Text"] // AbsoluteTiming versus just Import["testfile.txt"] and that removes just one test Import has to make. Then try ReadList["testfile.txt", "String"] // AbsoluteTiming which hasn't got the same sort of overhead. Also try Trace[Import["testfile.txt"]] to see exactly the internal functions used and the kind of tests performed. –  Pickett Sep 7 '13 at 13:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.