cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

Can simplify the script when opening text files with JSL?

Hello!

For example, if I import a text file like this, if my text file has a large number of columns, 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Save( "D:\Big.txt" );
Close( dt, nosave );
dt = Open(
	"D:\Big.txt",
	Charset( "gb2312" ),
	columns(
		New Column( "name", Character, "Nominal" ),
		New Column( "age", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "sex", Character, "Nominal" ),
		New Column( "height", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "weight", 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( 1 ),
		Data Starts( 2 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	)
);

can these repeated letters be replaced by variables?

 

abc="Numeric, \!"Continuous\!", Format( \!"Best\!", 12 )"

dt = Open(
	"D:\Big.txt",
	Charset( "gb2312" ),
	columns(
		New Column( "name", Character, "Nominal" ),
		New Column( "age",abc ),
		New Column( "sex", Character, "Nominal" ),
		New Column( "height",abc ),
		New Column( "weight",abc )
	),
	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( 1 ),
		Data Starts( 2 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	)
);

??

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: Can simplify the script when opening text files with JSL?

You can dramatically simplify the script - you just need to experiment with what is required.  I would always take out the column references and process them after the import, for e3xample:

 

dt = Open("$DOWNLOADS/Big Class.txt");
column(dt,"age") << set modeling type("nominal");
-Dave

View solution in original post

1 REPLY 1
David_Burnham
Super User (Alumni)

Re: Can simplify the script when opening text files with JSL?

You can dramatically simplify the script - you just need to experiment with what is required.  I would always take out the column references and process them after the import, for e3xample:

 

dt = Open("$DOWNLOADS/Big Class.txt");
column(dt,"age") << set modeling type("nominal");
-Dave

Recommended Articles