Preprocessing using readtable()
古いコメントを表示
I have a CSV file that I read it as a table with 'readtable'. The original CSV file contains timestamps for a wide range of days. In most of the cases, I do not need that massive amount of timestamps available, because my analyze is centred in a shorter period. Let me put an example to explain better my problem:
The CSV file contains the timestamps in column 1. It starts at timestamp=1573377305, and it starts increasing the timestamps without a determined size, the next timestamp can be at 8 seconds, the third at 10 seconds and so on. What I know are the timestamps of my analysis, the beginning and the end, but I don't know the number of rows that correspond with that interval.
For instance: my timestamps
1573377305
1573377312
1573377326
1573377334
1573377349
1573377355
1573377365
1573377373
1573377386
1573377393
1573377404
1573377416
1573377427
1573377433
1573377445
1573377455
1573377465
1573377475
1573377485
Imagine that my timestamp for analysis is from 1573377326 to 1573377433. I don't want to read all the previous and end information with readtable(). In this case, I could do DataLines = [4 15], but it is an illustrative example. Imagine that you have much more than 20 timestamps, and what you know is the timestamp from beginning to end.
If I upload all the data with 'readtable()', it is inefficient as I am loading information that I am not going to use. How can I do to select the precise interval I am going to use before using readtable()? Or how can I do this process more efficient?
2 件のコメント
Turlough Hughes
2019 年 11 月 18 日
Can you determine which lines of the file you want to read before reading it?
Neko Benítez
2019 年 11 月 18 日
採用された回答
その他の回答 (1 件)
Walter Roberson
2019 年 11 月 18 日
0 投票
Use detectImportOptions() on the csv file, and store the result to a variable. Now modify the DataLines property of the import options to be the numbers of the rows you want to read in. Now readtable() passing in those import options.
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!