How can I load a large csv file?
이전 댓글 표시
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~~~
답변 (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
zheng
2013년 4월 16일
I see, the fact that you have text in the last column will prevent you from using CSVREAD or DLMREAD efficiently.
zheng
2013년 4월 30일
Cedric
2013년 4월 30일
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
2013년 4월 30일
Cedric
2013년 4월 30일
But which columns do you need? all? And what kind of processing/comparison do you have to perform?
카테고리
도움말 센터 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!