5
$\begingroup$

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

$\endgroup$
7
$\begingroup$

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"];`
$\endgroup$
  • $\begingroup$ Thank a lot, I will try this. $\endgroup$ – Kiril Danilchenko Dec 16 '18 at 9:26
  • 1
    $\begingroup$ Since you have 32GB, you can of course increase the number after "-Xm" $\endgroup$ – FredrikD Dec 16 '18 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$ – Albert Retey Dec 16 '18 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 Dec 17 '18 at 7:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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