How can I load a large csv file?
Show older comments
I have a large csv file (6GB) and try to load it into MATLAB and save it into structure file.
I am currrently using textscan, and MATLAB freeze and the computer stopped responding after a certain time.
The file has 54,200,000 lines with 10 data in each line. I tried loading only few columns at a time, and it is still not working.
Is there a way I can load them all at once?
Thank you in advance~~~
Answers (1)
Did you try using CSVREAD and DLMREAD? The latter would allow you loading the file by block.
Also, what type of data is stored in the file? Could you copy/paste the first two rows here? Storing and array of size 54,200,000 x 10 as double requires a little more than 4GB RAM. What kind of system are you working with? If it can't handle this, you could read by block and convert into a smaller type/class for storing.
6 Comments
zheng
on 16 Apr 2013
I see, the fact that you have text in the last column will prevent you from using CSVREAD or DLMREAD efficiently.
zheng
on 30 Apr 2013
Cedric
on 30 Apr 2013
No problem! What structure does your structure file have? Do you need all the data from all files present in memory for treatment before you can start building this file, or could you treat the whole by smaller chunks (i.e. import a CSV file, export part of the structure file, import the second CSV file, export the next part of the structure file, etc)? Also, do you need all the columns of the input files or only a few of them?
zheng
on 30 Apr 2013
Cedric
on 30 Apr 2013
But which columns do you need? all? And what kind of processing/comparison do you have to perform?
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!