フィルターのクリア

Big CSV file read in matlab

54 ビュー (過去 30 日間)
Sudipta Das
Sudipta Das 2024 年 7 月 2 日 4:08
コメント済み: Rik 2024 年 7 月 3 日 7:11
I have a CSV file of 5 columns and unknown rows (all of these are number data), Its size is 45 GB.
I want to read it in MATLAB and plot it against the time.
Is there any way to do it ?
  3 件のコメント
Sudipta Das
Sudipta Das 2024 年 7 月 2 日 4:53
How to do that ?
I am beginner with big data handling
Rik
Rik 2024 年 7 月 2 日 7:10
I was putting it in a comment, then I realized it was actually an answer, so see below.

サインインしてコメントする。

回答 (2 件)

Aditya
Aditya 2024 年 7 月 2 日 4:27
Hi Sudipta,
Handling a 45 GB CSV file in MATLAB can be challenging due to memory constraints. You can use MATLAB's functions such as "datastore" function to handle large files efficiently by reading and processing the data in chunks.
For detailed guidance, please refer to this MATLAB Answer: Loading very large CSV files (~20GB) - MATLAB Answers - MATLAB Central (mathworks.com)
Additionally, you can read more about the `datastore` function here: Getting Started with Datastore - MATLAB & Simulink - MathWorks India
I hope this helps!

Rik
Rik 2024 年 7 月 2 日 7:11
You can use fgetl to read a single line. Do that in a loop to retrieve 5000 lines (or something like that). Then you do whatever sumarization you need (histcounts, 2D heatmap, whatever). Then you can continue with the next 5000 lines.
Note that fgetl returns a char vector you will have to parse yourself (e.g. with sscanf (yes, double s)). You might also want to check what happens with the last chunk (which is unlikely to be exactly your chunk size).
The beauty of this system is that you store intermediate values, so you can pause and continue if you track the number of completed chunks.
  1 件のコメント
Rik
Rik 2024 年 7 月 3 日 7:11
Did you try this solution already? I couldn't easily tell what exactly you edited in the question.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by