Subscribe Bookmark RSS Feed

Automatically Open and Join a text file Linked From JMP Column

d_barnett

Community Trekker

Joined:

Nov 30, 2011

I have a data table that creates a link to a text file saved in a folder. Is there a way to get JMP to open this automatically in a separate data table?

A slight complication is that I will have identical links in different rows

8437_pastedImage_0.png

Ideally I would like JMP to open these files up then link their sample numbers to the one in the original table ( listed as 1-17 here).

So file in folder_12345 will contain sample 1-6, folder_23456 will contain sample 7-12 and folder_34567 will contain sample 13-17 in a column in these files

8441_pastedImage_1.png8442_pastedImage_2.png8443_pastedImage_3.png

So that I would end up with the following joined table

8444_pastedImage_4.png

I hope this all makes sense and this would be a major benefit to my process workflow for JMP.

David

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Try to set i = 1 (instead of i = 0) both before and within the ForEachRow()-loop. That should skip first row.

4 REPLIES
ms

Super User

Joined:

Jun 23, 2011

This code may work for you. It assumes the column Summary file is sorted and that there aren't missing values in the text files.

dt = Current Data Table(); // Table with links

dt << New Column("Result", character);

delim = (",\!t\!n\!r"); //Add your delimiter..

sumtext = Load Text File(:Summary file[1]);

i = 0;

For Each Row(

    If(Row() > 1,

        If(:Summary file != Lag(:Summary file, 1),

            sumtext = Load Text File(:Summary file);

            i = 0;

        )

    );

    i++;

    :Result = Word(2 * i, sumtext, delim);

);

d_barnett

Community Trekker

Joined:

Nov 30, 2011

it is almost there apart from it picks up the headers from any rows and puts them into the data column

8445_pastedImage_0.png

what is really needed is it to ignore and headers apart from the first summary table ( so the 'should be' not the 'result'

Solution

Try to set i = 1 (instead of i = 0) both before and within the ForEachRow()-loop. That should skip first row.

d_barnett

Community Trekker

Joined:

Nov 30, 2011

I made the change and found it didn't quite work but with changing the I=0 to I=1 within the ForEachRow()-loop I have now got it to work!!

here is the final script that I have

dt = Current Data Table();

dt << New Column( "Result", character );

delim = ",

 

";

sumtext = Load Text File( :Summary file[1] );

i = 1;

For Each Row(

If( Row() > 1,

If( :Summary file != Lag( :Summary file,1 ),

sumtext = Load Text File( :Summary file );

i = 1;

);

i++;

:Result = Word( 2 * i, sumtext, delim );

);

Many regards and thanks

David