I try to load a huge CSV file (~ 4 Gbyte), the data is both numeric and textual.
So, I can't load the data as a string.

str = OpenRead["train.csv"];
data = ReadList[str, String];

When I try to Import the file directly, my notebook is crash ( Win 10, WL 11.3, and my PC has 32G of RAM). The link to the data: https://www.kaggle.com/c/microsoft-malware-prediction/data To deal with this issue, I split the original file to a few parts and load each one and save in ".mx" format. Any suggestion on how to load the file in a more efficient way


1 Answer 1


I recognize this when larger files and/or depending on fileformats. A brute force solution is to increase the size for the java virtual machine, for example

`<< JLink`;InstallJava[];
ReinstallJava[JVMArguments -> "-Xmx6144m"];`
  • $\begingroup$ Thank a lot, I will try this. $\endgroup$ Commented Dec 16, 2018 at 9:26
  • 1
    $\begingroup$ Since you have 32GB, you can of course increase the number after "-Xm" $\endgroup$
    – FredrikD
    Commented Dec 16, 2018 at 10:04
  • $\begingroup$ Have you actually tried that for CSV files? While there are several formats which are imported via java, I am not sure but think that importing CSV does not even use java, so changing the java stack size might not help in this case... $\endgroup$ Commented Dec 16, 2018 at 20:18
  • $\begingroup$ Good point. Is there any documentation on what Import uses for different formats? If import of CSV doesn't use Java then increasing the memory will not help. My own experience is that Import is a great function but a bit too "black boxy" and seems to be undergoing changes. E.g. I have programs that worked with 10.x that stopped working with 11.3 due to Unicode issues. $\endgroup$
    – FredrikD
    Commented Dec 17, 2018 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.