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!
  • See how to use the JMP Marketplace – Free tools to expand JMP capabilities. Register. July 10, 2 pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles