フィルターのクリア

Import large txt partially

2 ビュー (過去 30 日間)
Felix Lopez Hoffmann
Felix Lopez Hoffmann 2024 年 1 月 16 日
回答済み: Ayush Modi 2024 年 1 月 16 日
Hello,
we use matlab to process data stored in large txt files (several GB) and import the data successfully using
readmatrix(dataPath,'OutputType','single');
of the size [many million, 20]
However, often we would like to import only two first few million rows for a faster test-processing and most importantly for a faster import, which often takes several minutes.
Which is the most efficient way to import onkly the first x rows of txt file containing a matrix?
We would like to know this both for the newest and for the R2020b version.
Best regards
Felix

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2024 年 1 月 16 日

Ayush Modi
Ayush Modi 2024 年 1 月 16 日
Hi Felix,
I understand you want to load only a portion of the data at once from large txt files.
You can achieve it using "readmatrix" function only by adding additional parameter "Range". Here is an example to demonstrate how you can achieve this:
limitedData = readmatrix('filename.txt',"Range",[1,1,3,3])
Please refer to the following MathWorks documentation for more information on the “readmatrix” function:
Hope this helps!

カテゴリ

Help Center および File ExchangeTall Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by