cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
‘New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit – register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
patriciafm811
Level II

Multi File Import Certain Tabs and Columns

I am trying to import multiple XLSX files (which I know how to do), but I only need certain tabs with certain columns. I don't need everything being imported. Is there a way to do this?

 

Using JMP 17. Can recreate with steps or JSL code.

6 REPLIES 6
txnelson
Super User

Re: Multi File Import Certain Tabs and Columns

The settings for inputting an .xlsx file has the ability to specify the specific worksheets to be input.  It also has the ability to specify the starting column and ending column

The Scripting Index has an entry that shows and example that has the input options displayed.

txnelson_0-1697032278284.png

 

Jim
patriciafm811
Level II

Re: Multi File Import Certain Tabs and Columns

Thank you. This works if I am doing each file one by one, but not multiple files at once. Do you know how to do this for multiple files at once?

mmarchandTSI
Level V

Re: Multi File Import Certain Tabs and Columns

As long as each xlsx is set up the same way, just iterate over a list of the files:

 

FPlist = {"$DESKTOP/temp.xlsx", "$DESKTOP/temp1.xlsx"};
For Each( {val}, FPlist,
	Open(
		val,
		Worksheets( {"Sheet1", "Sheet3"} ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 0 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 1 ),
			Headers Start on Row( 1 ),
			Data Starts on Row( 2 ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 0 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Column Separator String( "-" )
		)
	)
);
patriciafm811
Level II

Re: Multi File Import Certain Tabs and Columns

I have been trying to get that script to work and I cannot make it happen. 

mmarchandTSI
Level V

Re: Multi File Import Certain Tabs and Columns

Could be the worksheet settings won't work with your specific files.  This is how I got this script.  Open one file using the Excel wizard first.

 

mmarchandTSI_0-1697044301686.png

Choose the worksheets you want and make sure the data preview looks right.

mmarchandTSI_1-1697044403585.png

After import, open the "Source" table script from one of the newly-created tables and copy it.

mmarchandTSI_2-1697044561713.png

Adapt that script for the For Each() function by replacing the absolute path with the val variable and inserting the list of desired worksheets into the proper parentheses.

 

I hope that all makes sense.  If you still have issues with it, please post the error message.

patriciafm811
Level II

Re: Multi File Import Certain Tabs and Columns

Ok. That got me much closer! Thank you!