Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
aaronjiang
Level I

Add column names for my data

I have many CSV files that came in directly with data but no column names. I am wondering how can I script to add column names for these data? Current column name is whatever the first number for each column. 

3 REPLIES 3
Highlighted
txnelson
Super User

Re: Add column names for my data

It seems like you need to change your Excel preferences, to read in the first line as the column names.  If you edit the "Source" entry in the data table, you should see what line the headers are on, and what line the data starts on.

 

Short of this, this little script will take the values in row 1, and make them the column headers

names default to here(1);
dt=current data table();
for(I=1,i<=Ncols(dt),i++,
     column(i) << set name(column(i)[1])
);
Jim
Highlighted
aaronjiang
Level I

Re: Add column names for my data

Thanks for the response. My issue is I don't have a column name included in my original data table from CSV. The JMP just directly read my first row in my CSV file as the column name. Do you know there is a way that I can insert column name into data table from JMP?

Highlighted
txnelson
Super User

Re: Add column names for my data

You need to use the Excel Wizard when openning the spreadsheet.  It will allow you to not read in the headers.  All you need to do, is to go to 

     File==>Open

then navigate to the Excel file you want to read in

Single click on the file you want to read in, and then click on the down arrow next to the Open, and select Excel Wizard.  It will walk you through the options on how to read in your Excel File.

wizard.PNG

Once you have read in one file, you can right click on the "Source" green triangle in the Table Panel in the upper left corner of the JMP Data table.  If you select Edit, you will see the JSL that you can use to read in the Excel Files

Jim
Article Labels

    There are no labels assigned to this post.