>> T = cssm( 'h:\m\cssm\example.txt' )
T =
76×3 table
Var1 Var2 info
_____ _____ __________________
27.32 32.8 "header 1 do need"
27.33 32.68 "header 1 do need"
27.05 32.73 "header 1 do need"
...
27.53 32.66 "header 2 do need"
27.68 32.98 "header 2 do need"
27.77 32.27 "header 2 do need"
27.49 32.35 "header 3 do need"
27.84 32.17 "header 3 do need"
27.83 32.16 "header 3 do need"
function T = cssm( ffs )
str = fileread( ffs );
ixs = find( str=='*', 1,'first' ) +1;
str = str( ixs : end );
[ blocks, matches ] = strsplit( str, '(?m)^#[^\r\n]*' ...
, 'DelimiterType','RegularExpression' );
blocks(1) = [];
len = length( blocks );
num = cell( len, 2 );
for jj = 1 : len
num(jj,:) = textscan( blocks{jj}, '%f%f' );
end
heights = cellfun( @numel, num(:,1) );
T = table( 'Size' , [sum( heights ),3] ...
, 'VariableTypes' , {'double','double','string'} ...
, 'VariableNames' , {'Var1','Var2','info'} );
ix1 = 1;
for jj = 1 : len
ix2 = ix1 + heights(jj) - 1;
T.Var1(ix1:ix2) = num{jj,1};
T.Var2(ix1:ix2) = num{jj,2};
T.info(ix1:ix2) = repmat( string(matches{jj}(3:end)), heights(jj),1 );
ix1 = ix2 + 1;
end
end