I have around 240 files with lots of data, I have been using Import[] to import these data for further processing. But as my simulations are growing bigger, I am having lots of difficulty importing them, my computer is freezing and lagging (my computer has 6GB RAM). I was wondering if there is a better (less memory intensive) option to import these files?
I have been using the following loop command to import this data as strings and then converting them to numbers
Rawdata = Table[
s = ToString[j];
Import["C:\\Users\\Downloads\\Run 6 new z=45 sigma =0.845\\pinocchio." <>
StringTake[s,2] <> "." <> StringDrop[s,2] <> ".example.catalog.out",
"Data"],
{j, 200000, 420000, 1000}];
Is there an analogous way to import the files without using so much memory?
=.) the variable you want to clear, or use ClearAll or Remove. – Sjoerd C. de Vries May 08 '15 at 12:48DumpandGetas you suggested (although I thinkExport[filename,expression,"MX"]is slightly cleaner). Anyway, if you want the data to be accessable with other programs you could also look at specific file formats like HDF5 which are at least partially supported from Mathematica and will be a much better choice to store large numeric arrays, even a whole collection in one file... – Albert Retey May 08 '15 at 14:50$HistoryLength=0? if you don't do that Mathematica will remember all output you ever generated in a session. concerning import: if changing the simulation, I'd consider another format for your files, text is just not a very good encoding for numeric data. Other than that, you might find this question and answers to it helpful. If sticking with text, you can read lines with ReadList and type String instead of BindaryReadList as in the answer... – Albert Retey May 08 '15 at 23:34