Extract the certain rows from a tall array
조회 수: 2 (최근 30일)
이전 댓글 표시
I am working on a text file with 22 GB consisting of around 180 million rows and 17 columns. I want to extract the specific raws (e.g. 3rd to 100th row, and only the 2nd column) and put it in memory (i.e. gather) instead of leaving it as unevaluated data.
data='D:\...\SQLDataExport.txt';
ds = tabularTextDatastore(data);
t_array=tall(ds);
trip=gather(t_array(2:100,2:2));
This would take much longer than I expected. A wierd thing is that if I extract data from the beginning (e.g. 1st row to 100th row, and only the 2nd column). It takes much much shorter time to complete.
data='D:\...\SQLDataExport.txt';
ds = tabularTextDatastore(data);
t_array=tall(ds);
trip=gather(t_array(1:100,2:2));
From my understanding, they both put a matrix about 100 by 1 into memory. Why would the first take much much longer than the second?
댓글 수: 0
답변 (1개)
Rajani Mishra
2019년 7월 19일
Hi,
I think the difference between the time taken for rows 1:100 and 2:100 can be because for rows between 1 to 100, just first 100 rows are extracted. For rows between any N:M full numeric indexing algorithm is used. A lot more work is done as numeric indexing is geared up for tall index which in turn causing the delay.
You can try using head for speeding up, like this:
trip=gather(head(t_array(2:100,2:2),99));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tall Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!