cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-718508%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9C%A8%E5%BE%AA%E7%92%B0%E4%B8%AD%E5%9E%82%E7%9B%B4%E9%80%A3%E6%8E%A5%E6%99%82%E7%AF%80%E7%9C%81%E5%85%A7%E5%AD%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-718508%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%95%8F%E5%80%99%EF%BC%81%3C%2FP%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%98%97%E8%A9%A6%E5%B0%87%E7%9B%AE%E9%8C%84%E4%B8%AD%E5%A4%9A%E5%80%8B%E8%A1%A8%E7%9A%84%E6%9F%A5%E8%A9%A2%E7%B5%90%E6%9E%9C%E9%80%A3%E6%8E%A5%E5%88%B0%E4%B8%80%E5%80%8B%E8%A1%A8%E4%B8%AD%E3%80%82%E6%88%91%E6%AD%A3%E5%9C%A8%E4%BD%BF%E7%94%A8%E5%BE%AA%E7%92%B0%E4%BE%86%E8%AE%80%E5%8F%96%2F%E6%9F%A5%E8%A9%A2%E8%A1%A8%E4%B8%A6%E9%80%A3%E6%8E%A5%E7%B5%90%E6%9E%9C%E3%80%82%E7%B5%90%E6%9E%9C%E8%A1%A8%E5%BE%88%E5%A5%BD%EF%BC%8C%E4%BD%86%E6%AF%8F%E5%80%8B%E4%B8%AD%E9%96%93%E4%B8%B2%E8%81%AF%E8%A1%A8%E4%B8%8D%E6%96%B7%E6%89%93%E9%96%8B%E6%B6%88%E8%80%97%E8%A8%98%E6%86%B6%E9%AB%94%E3%80%82%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E6%84%9F%E8%AC%9D%E6%82%A8%E6%8F%90%E4%BE%9B%E4%BB%BB%E4%BD%95%E5%BB%BA%E8%AD%B0%EF%BC%8C%E4%BB%A5%E9%81%BF%E5%85%8D%E9%96%8B%E5%95%9F%E6%AF%8F%E5%80%8B%E4%B8%AD%E9%96%93%E7%B5%90%E6%9E%9C%E8%A1%A8%EF%BC%8C%E8%80%8C%E5%8F%AA%E6%98%AF%E6%9B%B4%E6%96%B0%E8%B3%87%E6%96%99%E6%A1%86%EF%BC%8C%E8%A9%B2%E8%B3%87%E6%96%99%E6%A1%86%E5%83%85%E5%9C%A8%E5%BE%AA%E7%92%B0%E5%AE%8C%E6%88%90%E5%BE%8C%E6%89%8D%E8%83%BD%E9%A1%AF%E7%A4%BA%E7%82%BA%E7%B5%90%E6%9E%9C%E8%A1%A8%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E4%BD%BF%E7%94%A8%20JMP%2017%20Pro%E3%80%82%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enames%20default%20to%20here(1)%3B%3CBR%20%2F%3EdirLoc%3DPick%20Directory(%22Select%20a%20directory%22%2C%20%22myDirectory%5C%22)%3B%0AfileList%20%3D%20Files%20In%20Directory(dirLoc)%3B%0Adt1%20%3D%20open(dirLoc%20%7C%7C%20fileList%5B1%5D)%3B%0Adt1%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0Ax%3Ddt1%20%26lt%3B%26lt%3B%20Subset%20(%20Output%20Table%20Name(%22T1%22)%20)%3B%0AClose(dt1%2C%20NoSave)%3B%0AFor(i%20%3D%202%2C%20i%20%26lt%3B%3D%20N%20Items(%20fileList%20)%2C%20i%2B%2B%2C%0A%09dt%20%3D%20open(dirLoc%20%7C%7C%20fileList%5Bi%5D%20)%3B%0A%09dt%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0A%09y%20%3D%20dt%20%26lt%3B%26lt%3B%20Subset%20(%20Output%20Table%20Name(%22Temp%22))%3B%0A%09x%20%3D%20x%20%26lt%3B%26lt%3B%20Concatenate(%20y)%3B%0A%09Close(dt%2C%20NoSave)%3B%0A%09Close(y%2C%20NoSave)%3B%0A)%3B%0Aresult%20%3D%20x%26lt%3B%3CSUBSET%3E%3C%2FSUBSET%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%20%3C%2FCODE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3CLINGO-LABS%20id%3D%22lingo-labs-718508%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%E8%87%AA%E5%8B%95%E5%8C%96%E5%92%8C%E8%85%B3%E6%9C%AC%E7%B7%A8%E5%AF%AB%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3C%2FCODE%3E%3CLINGO-SUB%20id%3D%22lingo-sub-718539%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%9C%A8%E5%BE%AA%E7%92%B0%E4%B8%AD%E5%9E%82%E7%9B%B4%E9%80%A3%E6%8E%A5%E6%99%82%E7%AF%80%E7%9C%81%E5%85%A7%E5%AD%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-718539%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThere%20might%20be%20some%20misunderstanding%20here.%20%20Doing%20%3CCODE%20class%3D%22%20language-jsl%22%3Ex%20%26lt%3B%26lt%3B%20Concatenate(%20x%2C%20y%20)%3C%2FCODE%3E%20will%20not%20update%20%3CCODE%20class%3D%22%20language-jsl%22%3Ex%3C%2FCODE%3E%2C%20it%20will%20create%20a%20new%20table.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3ETo%20update%20%3CCODE%20class%3D%22%20language-jsl%22%3Ex%3C%2FCODE%3E%20with%20the%20values%20of%20%3CCODE%20class%3D%22%20language-jsl%22%3Ey%3C%2FCODE%3E%2C%20use%20the%20literal%20expression%20%3CCODE%20class%3D%22%20language-jsl%22%3Ex%20%26lt%3B%26lt%3B%20Concatenate(%20y%2C%20%22Append%20to%20First%20Table%22%20)%3C%2FCODE%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E5%8F%A6%E5%A4%96%EF%BC%8C%E8%80%83%E6%85%AE%E5%B0%87%E6%89%80%E6%9C%89%E9%80%99%E4%BA%9B%E4%BD%9C%E7%82%BA%E7%A7%81%E6%9C%89%E8%A1%A8%E9%80%B2%E8%A1%8C%E4%BB%A5%E7%AF%80%E7%9C%81%E8%B3%87%E6%BA%90%EF%BC%8C%E7%84%B6%E5%BE%8C%E5%9C%A8%E6%9C%80%E5%BE%8C%E9%A1%AF%E7%A4%BA%E8%A9%B2%E8%A1%A8%EF%BC%8C%E5%A6%82%E4%B8%8B%E6%89%80%E7%A4%BA%EF%BC%9A%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0AdirLoc%20%3D%20Pick%20Directory(%20%22Select%20a%20directory%22%2C%20%22myDirectory%5C%22%20)%3B%0AfileList%20%3D%20Files%20In%20Directory(%20dirLoc%20)%3B%0Adt1%20%3D%20Open(%20dirLoc%20%7C%7C%20fileList%5B1%5D%2C%20Private%20)%3B%0Adt1%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0Ax%20%3D%20dt1%20%26lt%3B%26lt%3B%20Subset(%20Output%20Table%20Name(%20%22T1%22%20)%2C%20Private%20)%3B%0AClose(%20dt1%2C%20NoSave%20)%3B%0A%0AFor(%20i%20%3D%202%2C%20i%20%26lt%3B%3D%20N%20Items(%20fileList%20)%2C%20i%2B%2B%2C%0A%09dt%20%3D%20Open(%20dirLoc%20%7C%7C%20fileList%5Bi%5D%2C%20Private%20)%3B%0A%09dt%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0A%09y%20%3D%20dt%20%26lt%3B%26lt%3B%20Subset(%20Output%20Table%20Name(%20%22Temp%22%20)%2C%20Private%20)%3B%0A%09x%20%26lt%3B%26lt%3B%20Concatenate(%20y%2C%20%22Append%20to%20First%20Table%22%20)%3B%0A%09Close(%20dt%2C%20NoSave%20)%3B%0A%09Close(%20y%2C%20NoSave%20)%3B%0A)%3B%0A%0Ax%20%26lt%3B%26lt%3B%20Set%20Name(%20%22Result%22%20)%3B%0Ax%20%26lt%3B%26lt%3B%20New%20Data%20View%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-718526%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%9C%A8%E5%BE%AA%E7%92%B0%E4%B8%AD%E5%9E%82%E7%9B%B4%E9%80%A3%E6%8E%A5%E6%99%82%E7%AF%80%E7%9C%81%E5%85%A7%E5%AD%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-718526%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%84%9F%E8%AC%9D%E6%82%A8%E6%8F%90%E5%87%BA%E9%99%84%E5%8A%A0%E8%80%8C%E4%B8%8D%E6%98%AF%E4%B8%B2%E8%81%AF%E7%9A%84%E5%BB%BA%E8%AD%B0%E3%80%82%E5%AF%A6%E9%9A%9B%E4%B8%8A%E6%88%91%E5%98%97%E8%A9%A6%E4%BA%86%E9%99%84%E5%8A%A0%E4%BB%A5%E5%8F%8A%E5%A6%82%E4%B8%8B%E6%89%80%E7%A4%BA%E3%80%82%E5%95%8F%E9%A1%8C%E6%98%AF%EF%BC%8C%E6%AF%8F%E6%AC%A1%E9%99%84%E5%8A%A0%E5%88%B0%E5%BE%AA%E7%92%B0%E4%B8%AD%E6%99%82%EF%BC%8C%E5%AE%83%E9%83%BD%E6%9C%83%E5%BD%88%E5%87%BA%E6%89%80%E6%9C%89%E4%B8%AD%E9%96%93%E8%A1%A8%E3%80%82%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ex%20%26lt%3B%26lt%3B%20Concatenate(x%2Cy)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E4%BB%BB%E4%BD%95%E6%83%B3%E6%B3%95%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-718525%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%9C%A8%E5%BE%AA%E7%92%B0%E4%B8%AD%E5%9E%82%E7%9B%B4%E9%80%A3%E6%8E%A5%E6%99%82%E7%AF%80%E7%9C%81%E5%85%A7%E5%AD%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-718525%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%82%A8%E9%9C%80%E8%A6%81%E9%99%84%E5%8A%A0%E4%B8%B2%E8%81%AF%E7%9A%84%E8%A1%A8%E3%80%82%E9%A0%90%E8%A8%AD%E6%83%85%E6%B3%81%E4%B8%8B%EF%BC%8CJMP%20%E5%B0%87%E8%A1%A8%E9%80%A3%E6%8E%A5%E6%88%90%E4%B8%80%E5%80%8B%E6%96%B0%E8%A1%A8%E3%80%82%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enames%20default%20to%20here(1)%3BdirLoc%3DPick%20Directory(%22Select%20a%20directory%22%2C%20%22myDirectory%5C%22)%3B%0AfileList%20%3D%20Files%20In%20Directory(dirLoc)%3B%0Adt1%20%3D%20open(dirLoc%20%7C%7C%20fileList%5B1%5D)%3B%0Adt1%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0Ax%3Ddt1%20%26lt%3B%26lt%3B%20Subset%20(%20Output%20Table%20Name(%22T1%22)%20)%3B%0AClose(dt1%2C%20NoSave)%3B%0AFor(i%20%3D%202%2C%20i%20%26lt%3B%3D%20N%20Items(%20fileList%20)%2C%20i%2B%2B%2C%0A%09dt%20%3D%20open(dirLoc%20%7C%7C%20fileList%5Bi%5D%20)%3B%0A%09dt%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AAmount%20%26gt%3B%3D%20500%20)%3B%0A%09y%20%3D%20dt%20%26lt%3B%26lt%3B%20Subset%20(%20Output%20Table%20Name(%22Temp%22))%3B%0A%09x%20%26lt%3B%26lt%3B%20Concatenate(%20y%2C%20%22Append%20to%20First%20Table%22%20)%3B%0A%09Close(dt%2C%20NoSave)%3B%0A%09Close(y%2C%20NoSave)%3B%0A)%3B%0Aresult%20%3D%20x%26lt%3B%3CSUBSET%3E%3C%2FSUBSET%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%20%20%3C%2FCODE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
monir
Level I

Save memory while Concatenating vertically in loop

Greetings!

I am trying to Concatenate query results, from several tables in a directory, into one single table. I am using loop to read/query the tables and concatenate the results. The result table is fine but each intermediate concatenated tables keeps opening consuming the memory. 

 

Thank you for any suggestions to to avoid opening each intermediate result tables but just updating the data frame which can be displayed as the result table only after the loop is completed.

I am using JMP 17 Pro. 

 

names default to here(1);
dirLoc=Pick Directory("Select a directory", "myDirectory\"); fileList = Files In Directory(dirLoc); dt1 = open(dirLoc || fileList[1]); dt1 << Select Where( :Amount >= 500 ); x=dt1 << Subset ( Output Table Name("T1") ); Close(dt1, NoSave); For(i = 2, i <= N Items( fileList ), i++, dt = open(dirLoc || fileList[i] ); dt << Select Where( :Amount >= 500 ); y = dt << Subset ( Output Table Name("Temp")); x = x << Concatenate( y); Close(dt, NoSave); Close(y, NoSave); ); result = x<<Subset ( Output Table Name("Result"));

 

3 REPLIES 3
ErraticAttack
Level VI

Re: Save memory while Concatenating vertically in loop

You need to append the concatenated tables.  By default JMP concatenates tables into a new table.

 

names default to here(1);dirLoc=Pick Directory("Select a directory", "myDirectory\");
fileList = Files In Directory(dirLoc);
dt1 = open(dirLoc || fileList[1]);
dt1 << Select Where( :Amount >= 500 );
x=dt1 << Subset ( Output Table Name("T1") );
Close(dt1, NoSave);
For(i = 2, i <= N Items( fileList ), i++,
	dt = open(dirLoc || fileList[i] );
	dt << Select Where( :Amount >= 500 );
	y = dt << Subset ( Output Table Name("Temp"));
	x << Concatenate( y, "Append to First Table" );
	Close(dt, NoSave);
	Close(y, NoSave);
);
result = x<<Subset ( Output Table Name("Result"));

  

Jordan
monir
Level I

Re: Save memory while Concatenating vertically in loop

Thanks for your suggestion to append instead of concatenation. Actually I tried appending as well as shown below. The problem is, it pops up all the intermediate table every time it is appended in the loop.

 

x << Concatenate(x,y);

 Any thought?

ErraticAttack
Level VI

Re: Save memory while Concatenating vertically in loop

There might be some misunderstanding here.  Doing x << Concatenate( x, y ) will not update x, it will create a new table.

 

To update x with the values of y, use the literal expression x << Concatenate( y, "Append to First Table" )

 

Also, think about doing all this as private tables to conserve resources, then at the end show the table, like this:

 

Names Default To Here( 1 );
dirLoc = Pick Directory( "Select a directory", "myDirectory\" );
fileList = Files In Directory( dirLoc );
dt1 = Open( dirLoc || fileList[1], Private );
dt1 << Select Where( :Amount >= 500 );
x = dt1 << Subset( Output Table Name( "T1" ), Private );
Close( dt1, NoSave );

For( i = 2, i <= N Items( fileList ), i++,
	dt = Open( dirLoc || fileList[i], Private );
	dt << Select Where( :Amount >= 500 );
	y = dt << Subset( Output Table Name( "Temp" ), Private );
	x << Concatenate( y, "Append to First Table" );
	Close( dt, NoSave );
	Close( y, NoSave );
);

x << Set Name( "Result" );
x << New Data View;

 

Jordan