在循環中垂直連接時節省內存問候!
我正在嘗試將目錄中多個表的查詢結果連接到一個表中。我正在使用循環來讀取/查詢表並連接結果。結果表很好,但每個中間串聯表不斷打開消耗記憶體。
感謝您提供任何建議,以避免開啟每個中間結果表,而只是更新資料框,該資料框僅在循環完成後才能顯示為結果表。
我正在使用 JMP 17 Pro。
names default to here(1);<BR />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></SUBSET>
<LINGO-LABS id="lingo-labs-718508" slang="en-US" mode="CREATE"><LINGO-LABEL>自動化和腳本編寫</LINGO-LABEL></LINGO-LABS>回覆:在循環中垂直連接時節省內存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" )
另外,考慮將所有這些作為私有表進行以節省資源,然後在最後顯示該表,如下所示:
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;
回覆:在循環中垂直連接時節省內存感謝您提出附加而不是串聯的建議。實際上我嘗試了附加以及如下所示。問題是,每次附加到循環中時,它都會彈出所有中間表。
x << Concatenate(x,y);
任何想法?
回覆:在循環中垂直連接時節省內存您需要附加串聯的表。預設情況下,JMP 將表連接成一個新表。
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></SUBSET>