cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

How to provide column names manually in script for importing multiple text files?

Hello,

 

I was able to use the import multiple files tool to get a Skelton script. I would like to add column names to created table through the script. Is there a way to do that?

Singhthisside_0-1708963754608.png

 

1 REPLY 1
jthi
Super User

Re: How to provide column names manually in script for importing multiple text files?

You could for example have a list of column names and then loop over that list while setting the names. Depending where you get the names how you might want to loop might be different

 

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Column 4", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

mycols = {"a", "b", "c", "d"};
wait(1); // for demo purposes

For Each({colname, idx}, dt << Get Column Names("String"),
	Column(dt, colname) << Set Name(mycols[idx]);
);

You might also be already add the names in the import script but it might depend on your file

 

-Jarmo