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!

 채택된 답변

Jan
Jan 2022년 4월 26일
S = readlines(filename);
Index = find(startsWith(S, '#'));
Len = diff(Index) - 1 % Length of the blocks

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 4월 26일

댓글:

2022년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by