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
sam_t
Level III

Table keep first split character

Hi,

 

I have a CSV file in each row has different pipe | data. The first row is the header name.

Do I loop every single row to get the first word, put it into a new table and export to CSV?

What's the better approach?

 

The example below is I would keep 1.611120 and ignore the rest.

 

Word( 1, "1.611120|10.63220|111.0111100|11110.633320|-987654|ABCDE||12222.020|||98|ABCD|", "|" );
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Table keep first split character

If you use the Data Previewer for the first input, you can have JMP provide you with the JSL to open future instances.  Once the data table has been created, using the Data Previewer, just go to the "Source" element in the tables panel of the data table, pipe4a.PNG

right click on green triangle, and select "Edit"

pipe4.PNG

There you will find the JSL required to read in future instances of your .csv file

pipe5.PNG

Because the column names are contained within your .csv file, you can just completly remove the whole Columns() section from the code, and JMP will find all of the columns in your .csv file.

Jim

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Table keep first split character

I suggest you specify to use the Data with Preview option when opening the .csv file.  pipe1.PNG

It will allow you to specify the "|" as the separatorpipe2.PNG

Which will then end up reading in each of the fields as separate columns.pipe3.PNG

Which then you can just delete all of the columns you do not want

Jim
Highlighted
sam_t
Level III

Re: Table keep first split character

Thank you.

I was hoping to automate this with JSL.

Highlighted
txnelson
Super User

Re: Table keep first split character

If you use the Data Previewer for the first input, you can have JMP provide you with the JSL to open future instances.  Once the data table has been created, using the Data Previewer, just go to the "Source" element in the tables panel of the data table, pipe4a.PNG

right click on green triangle, and select "Edit"

pipe4.PNG

There you will find the JSL required to read in future instances of your .csv file

pipe5.PNG

Because the column names are contained within your .csv file, you can just completly remove the whole Columns() section from the code, and JMP will find all of the columns in your .csv file.

Jim

View solution in original post

Highlighted
sam_t
Level III

Re: Table keep first split character

Jim,

 

My columns names (first line) are different each time for each .csv file and it is a not a fix column #. I could have 10 columns or 50 columns of pipe data so I cannot hard code Column().

 

I only want to keep first pipe of the data.

 

Thanks.

 

 

Highlighted
txnelson
Super User

Re: Table keep first split character

As I had stated in my last response:

     "Because the column names are contained within your .csv file, you can just completly remove the whole Columns() section from the code, and JMP will find all of the columns in your .csv file."

 

So copy and paste the code.  Remove the Columns() section of the code.  Then change the path to a different .csv file, and you will see that the code will be able to open the new data table.

Jim
Article Labels

    There are no labels assigned to this post.