Subscribe Bookmark RSS Feed

How do you open multiple files and specify what the column names are for the files?

tsolomon

Community Trekker

Joined:

Oct 28, 2015

I found this script which opens multiple files but the columns in the files don't have a header and this script automatically converts the first row into column names. Do you know how to modify this to specify the first row is not the column names and specify the column names for each file if the names are all the same?

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

The 'Open()' command is very versatile, so has many options. Select 'Help > Scripting Index', type 'Open' in the search field at the upper left, and look for 'Open()' in the Items list. You can then inspect and run some examples. Example 2 contains the option 'Table Contains Column Headers( 0 )' which seems to be what you want.

4 REPLIES
tsolomon

Community Trekker

Joined:

Oct 28, 2015

Here is the script to open multiple files that I found on another posting.

Set Default Directory( "C:\Jan_24th\" );

files = Files In Directory( "C:\Jan_24th\" );

For( i = 1, i <= N Items( files ), i++,

          If( Ends With( files[i], ".csv" ),

                    Open( files[i] );

                    Text Box( Regex( files[i], "(.+?)_", "\1" ) ) << journal; // All text before first "_" in file i's name is journaled

          )

);

msharp

Super User

Joined:

Jul 28, 2015

This is a JMP preference.  Go to File >> Preferences (ctrl+k) and uncheck the box. 

10288_pastedImage_0.png

Similarly you can can script this with:

Set Preferences(Import Settings(Labels(0))) //off

Set Preferences(Import Settings(Labels(1))) //on

Be sure to turn the preference back on when you are done or else you are going to annoy your end user.

ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

The 'Open()' command is very versatile, so has many options. Select 'Help > Scripting Index', type 'Open' in the search field at the upper left, and look for 'Open()' in the Items list. You can then inspect and run some examples. Example 2 contains the option 'Table Contains Column Headers( 0 )' which seems to be what you want.

tsolomon

Community Trekker

Joined:

Oct 28, 2015

Thank you, this worked great!