Something like this.
// pick a test case...
f = savetextfile("$temp\deleteme.csv","1jan2000\!ntime,x,y,z\!n101,1,2,3\!n101,4,5,6");
//f = Save Text File( "$temp\deleteme.csv", "1jan2000\!nVIN\!ntime,x,y,z\!n102,1,2,3\!n102,4,5,6" );
text = Load Text File( f );
// count newlines before "time"
newline = "\!n\!r" | "\!r\!n" | "\!n" | "\!r";
n = 0;
Pat Match( // there are a lot of ways you could count newlines before "time"
text, // use the pattern matcher to loop through the text
Pat Pos( 0 ) +
Pat Repeat(
("time" + Pat Rem()) // found "time", skip to the end
| // OR...skip to the end of the line and count it
(Pat Break( "\!n\!r" ) + newline + Pat Test( n += 1; 1; ))
)
);
Show( n );
HEADERLINE = n + 1;
FIRSTDATALINE = n + 2;
Open(
f,
columns(
New Column( "time", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "x", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "y", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "z", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( HEADERLINE ),
First Named Column( 1 ),
Data Starts( FIRSTDATALINE ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
);
Craige