cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Nagraba
Level I

How do I get the import file settings right before concatenating files by a script?

I have several files in a specific format and and with the *.asc extension (example: two files as attached to this post). I have tried to make changes in the script uploaded by Bryan can be found here: https://community.jmp.com/t5/JMP-Scripts/Combine-multiple-txt-or-csv-files/ta-p/24083

 

It works well if I rename all my files to *.txt before running the script but otherviese it will not. I have tried to make changes into the script below (from Bryan) but still can not get it to work.

 

Can anyone help me getting the right mport file setting and *.asc filters in the script?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How do I get the import file settings right before concatenating files by a script?

You can use open("filename.asc","text") to get JMP to assume the file is a text file of data for import. I got this script out of the table after importing via the preview wizard. Since it has other options, it doesn't need "text". On the file-open dialog, set the filter to *.*, pick your file, then set the filter to *.txt and pick the preview wizard. Look in the imported table's source script to find...

Open(
	"C:\Users\...\Desktop\Example01.asc",
	columns(
		New Column( "Column 1", Character, "Nominal" ),
		New Column( "0s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "90s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "180s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "270s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "360s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "450s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "540s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "630s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "720s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "810s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "900s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "990s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1080s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1170s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1260s", Character, "Nominal" ),
		New Column( "1350s", Character, "Nominal" ),
		New Column( "1440s", Character, "Nominal" ),
		New Column( "1530s", Character, "Nominal" ),
		New Column( "1620s", Character, "Nominal" ),
		New Column( "1710s", Character, "Nominal" ),
		Omitted Column( . )
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Tab, 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" )
	)
)
Craige

View solution in original post

1 REPLY 1
Craige_Hales
Super User

Re: How do I get the import file settings right before concatenating files by a script?

You can use open("filename.asc","text") to get JMP to assume the file is a text file of data for import. I got this script out of the table after importing via the preview wizard. Since it has other options, it doesn't need "text". On the file-open dialog, set the filter to *.*, pick your file, then set the filter to *.txt and pick the preview wizard. Look in the imported table's source script to find...

Open(
	"C:\Users\...\Desktop\Example01.asc",
	columns(
		New Column( "Column 1", Character, "Nominal" ),
		New Column( "0s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "90s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "180s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "270s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "360s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "450s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "540s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "630s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "720s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "810s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "900s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "990s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1080s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1170s", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "1260s", Character, "Nominal" ),
		New Column( "1350s", Character, "Nominal" ),
		New Column( "1440s", Character, "Nominal" ),
		New Column( "1530s", Character, "Nominal" ),
		New Column( "1620s", Character, "Nominal" ),
		New Column( "1710s", Character, "Nominal" ),
		Omitted Column( . )
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Tab, 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" )
	)
)
Craige