Loading Large .txt files
이전 댓글 표시
Let's say I have a very very large .txt file with (200millions row & 11 columns= 200m-by-11 matrix). All data are numeric number value (e.g., 10, 100 ,200...) . My file is ~ 20GB
When I load this data in Matlab, the errors occurs: "Out of Memory"
clear;clc;filename = 'test42.txt'; load('test42.txt');P = test42(:,1:3);%get data=coordinate(x,y,z) from set of data "column" at (all row & column 1,2,3)
My PC system: win10-64 bit, RAM 16GB, core-i7, HDD:1TB; SSD 1TB
Actually, I just want to load the data contain only first 3 columns. It mean, the matrix that I want to get is: 200m-by-3 matrix. And with the reduce column, I hope Matlab is able to load data.
Do you know any way to read the whole dataset, or read the reduce data with only first 3 columns? Thanks.
The format of my file is like this.

채택된 답변
추가 답변 (1개)
Walter Roberson
2019년 6월 16일
0 개 추천
textscan() is more likely to succeed than some of the other alternatives.
Most reliable would be to pre-allocate all of the storage, and then to process chunks of the file at a time (for efficiency). For example, if you told textscan() to read 50 lines of the file, that would be just under 4 Kb, which would fit easily into MATLAB's "small blocks" storage strategy where it can extend an array in place if the array is sufficiently small. Copy the 50 rows into the master matrix, proceed to next chunk.
카테고리
도움말 센터 및 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!




