在循环中垂直连接时节省内存问候!
我正在尝试将目录中多个表的查询结果连接到一个表中。我正在使用循环来读取/查询表并连接结果。结果表很好,但每个中间串联表不断打开消耗内存。
感谢您提供任何建议,以避免打开每个中间结果表,而只是更新数据框,该数据框仅在循环完成后才能显示为结果表。
我正在使用 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>