Count number of lines between strings in a text file.
4 ビュー (過去 30 日間)
古いコメントを表示
I have a set of text files with varying amounts of information (i.e. different numbers of lines) in the header. One example file has the following header:
######################################################################
Test File Name: 202204221121
Timestamp: 360
Test Type: EMPTY Valve Selction: BOTH Valve Cycle Time: 2 Test Duration: 360
Pressure Offsets: -0.407,-0.106,-0.190,-0.372,-0.877
Pressure Scaling Data (Upstream down):
InMin,InMax,OutMin,OutMax
16501,18733,675.320,687.525
16101,21331,656.950,686.050
19887,23890,662.13,684.61
15685,20960,656.95,686.05
15276,17316,654.97,666.25
Hawser Scaling Data (lb units)
-1 -.5 -.25 -.125 0 .125 .25 .5 1
27445,33590,36514,37849,39040,40940,42447,45795,50644
27675,33733,36900,37733,39318,40586,41633,44150,49800
29547,33785,36515,37444,41439,41863,43196,45851,52125
######################################################################
How can I programmatically determine the number of lines between the "########" lines? Thanks!
0 件のコメント
採用された回答
Jan
2022 年 4 月 26 日
S = readlines(filename);
Index = find(startsWith(S, '#'));
Len = diff(Index) - 1 % Length of the blocks
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Testing Frameworks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!