Subscribe Bookmark RSS Feed

Concatenation of multiple tables

Christian

Community Trekker

Joined:

Jun 2, 2014

I have found a method in the forum that provided the capability of concatenating tables together. I have tried with a list of existing tables where the starting tables is of the same kind. Does somebody detect my fault?

Names Default To Here( 1 ); Clear Log(); Clear Symbols(); Close All(Data Tables, No Save);  Close All(Journals, No Save); Close All(Reports,No Save);
Path = "C:\Users\u387536\Documents\01 Data and Analysis\08 IP21 to JMP Data Integraton\Working Folder Data Read-In\Data\";
filelist = {};
filelist[1] = Open(Path||"file 1.jmp",private);
filelist[2] = Open(Path||"file 2.jmp",private);
filelist[3] = Open(Path||"file 3.jmp",private);
filefinal 	= "file 123.jmp";

nf=nitems(filelist); //number of items in the working list
cctable= New Table( "Combined data table ");//make an empty table
cctable << New Column( "Source", Character, Nominal );
For( iii = 2 , iii <= nf, iii++, //this starts the first loop
filenow = ( filelist[iii] );
fileopen=(filepath||filenow);
//dt=open(fileopen,private);
//dt=open(fileopen,importset,private);//Import settings used in the open argument
dt = filelist[1];
New Column( "Source", Character, Nominal );
:Source << set each value( filenow );
//dt<<new column("Source", character, nominal)<<set each value(9999);
dt << Run Formulas();
//add the current table to the bottom of the combined data table
cctable << Concatenate( Data Table( dt ), Append to first table );
//don't use "Create Source Column" argument
Close( dt, NoSave );//after concatenating the table, close it and move on
);//end of the first for loop

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Check and see the value of "filenow".  I assume you believe that it has just the value of the data table.  But what you will see is that it's value is:

     Data Table("the file name")

If what you want is just "the file name", you need to request it to be returned from "filenow"

     filenow << get name

I strongly recomment you read the Scripting Guide

     Help==>Books==>Scripting Guide

It will show how you can view what a variables value is by placing your cursor on the variable, or by using the show() function to see it, or to use the JSL debugger so you can step through the code and see exactly what the code is doing.

 

Jim
3 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

What error do you see in teh log, please ('Windows > Log')? Looks like 'filepath' is not assigned.

Christian

Community Trekker

Joined:

Jun 2, 2014

The error that pops up in the log is:

 

Wrong result type for expression for column Source{1} in access or evaluation of 'set each value' , set each value( filenow ) /*###*/




txnelson

Super User

Joined:

Jun 22, 2012

Solution

Check and see the value of "filenow".  I assume you believe that it has just the value of the data table.  But what you will see is that it's value is:

     Data Table("the file name")

If what you want is just "the file name", you need to request it to be returned from "filenow"

     filenow << get name

I strongly recomment you read the Scripting Guide

     Help==>Books==>Scripting Guide

It will show how you can view what a variables value is by placing your cursor on the variable, or by using the show() function to see it, or to use the JSL debugger so you can step through the code and see exactly what the code is doing.

 

Jim