I have modified the JSL that after the data table is created as it was in my initial response, I then reread the .txt file, and to read the units. It then add the units as Column Properties to the columns in the full data table.
Note: The units are not part of the column name. They are a column property. However, the units will be displayed automatically with the column.
theFile = //"
"L:\Documents\Discussion Group/cschultz32.txt";
dt = Open( theFile,
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, CSV( 0 ) ),
Treat Leading Zeros as Character( 1 ),
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( 4 ),
First Named Column( 1 ),
Data Starts( 6 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
);
dt << select where( Is Missing( Num( :sampleID ) ) == 1 | Is Missing( Num( :density ) ) );
dt << delete rows;
colNames = dt << get column names( string );
For( i = N Items( colNames ), i >= 1, i--,
col = colNames[i];
Column( col ) << set datatype( numeric ) << set modeling type( continuous );
If( Col Number( As Column( col ) ) == 0,
dt << delete columns( col )
);
);
// Read in the units and apply them
dtUnits = Open( theFile,
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, CSV( 0 ) ),
Treat Leading Zeros as Character( 1 ),
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( 4 ),
First Named Column( 1 ),
Data Starts( 5 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
);
dtUnits << select where(row()>1);
dtUnits << delete rows;
colNames = dt << get column names( string, numeric );
For Each( {col}, colNames,
units = Column( dtUnits, col )[1];
If( Is Missing( units ) == 0,
units = Substitute( units, "(", "", ")", "" );
Eval( Eval Expr( Column( dt, col ) << set property( "units", Expr( units ) ) ) );
);
);
close( dtUnits, nosave );