从列表中连接多个表使用此处的脚本我可以从任何文件夹中获取表的列表。我希望能够从创建的列表中连接表。我希望用户能够选择他/她可以加入哪些表,并预设要用于加入的列。
Path = Pick Directory("选择分析数据目录");
Files_All = 目录中的文件(路径);
NFS_All = N 项(Files_All);
文件={};
//删除非文本文件
对于 (f=1, f < NFS_All+1, f++,
如果(包含(Files_All[f],“.txt”)> 0,
插入(文件,Files_All[f]);
);
);
//提示选择单个文件
列表_NPr = {};
List_Pr = 文件;
PromptF = 新窗口("文件选择", << 模态,
V 列表框(
文本框(“选择所需的文件”),
文本框(” ”),
H 列表框(
V 列表框(
文本框(“要处理的文件:”),
Pr = 列表框(List_Pr, 宽度(350), nlines(30)),
按钮框(">>>> 删除所选>>>>",
List_NPr = concat(List_NPr, Pr << 被选中);
List_Pr = 删除(List_Pr, Pr << 获取选定的索引);
Pr << 设置项目(List_Pr);
NPr << 设置项目(List_NPr);
)),
文本框(” ”),
V 列表框(
Text Box("排除的文件:"),
NPr = 列表框(List_NPr, 宽度(350), nlines(30)),
按钮框("<<<< 添加选定的<<<<",
List_Pr = concat(List_Pr, NPr << 被选中);
List_NPr = 删除(List_NPr, NPr << 获取选定的索引);
Pr << 设置项目(List_Pr);
NPr << 设置项目(List_NPr);
)))));
等待(0);
文件=List_Pr;
NFS = N 个项目(文件);
);
回复:从列表中连接多个表请将您的解决方案标记为“解决方案”。我也会将 Ian 标记为解决方案。
回复:从列表中连接多个表谢谢你!
我实际上想通了。
如果有人愿意的话,这是我的致意。
Clear Globals();
Clear Symbols();
Main Menu("Minimize All");
//Set text export preferences
//Preferences(Export Settings(Export Table Headers));
//Preferences(Export Settings(End of Field(Tab)));
//Initial prompt to select split level
Prompt = New Window ("Output Selection", <<MODAL> 0,
Insert Into(Files,Files_All[f]);
);
);
//Prompt to select individual files
List_NPr = {};
List_Pr = Files;
PromptF = New Window("File Selection", << Modal,
V List Box(
Text Box ("Select Desired Files"),
Text Box(" "),
H List Box(
V List Box(
Text Box("Files to join:"),
Pr = List Box(List_Pr, width(350), nlines(30)),
Button Box(">>>> Remove Selected >>>>",
List_NPr = concat(List_NPr, Pr << Get Selected);
List_Pr = remove(List_Pr, Pr << Get Selected Indices);
Pr << Set Items(List_Pr);
NPr << Set Items(List_NPr);
)),
Text Box(" "),
V List Box(
Text Box("Files Excluded:"),
NPr = List Box(List_NPr, width(350), nlines(30)),
Button Box("<<<< Add Selected <<<<",
List_Pr = concat(List_Pr, NPr << Get Selected);
List_NPr = remove(List_NPr, NPr << Get Selected Indices);
Pr << Set Items(List_Pr);
NPr << Set Items(List_NPr);
)))));
wait(0);
Files = List_Pr;
NFS = N Items(Files);
// table that others join
Fullpath = Path||Files[1];
DT_old = Open( Fullpath,private);
DT_old << Minimize Window;
//loop to join other tables
For (a=2, a < NFS+1, a++,
Fullpath = Path||Files[a];
DT_new = Open( Fullpath,private);
DT_new << Minimize Window;
join_name = "Limits" || char(a);
dt_old << join( with(data table(dt_new)),
Merge Same Name Columns,
By Matching Columns(
:A = :A,
:B = :B,
:C = :C,
),
Drop multiples( 1, 0 ),
Name( "Include non-matches" )(1, 1),
Output Table( join_name )
);
close(dt_old, nosave);
dt_old = data table(join_name);
);
</MODAL>回复:从列表中连接多个表那么你的问题是什么? 您的脚本的最后一行有一个无关的右括号,并且您没有捕获最终列表。
这是您修改后的 JSL。FList 包含用户选择的文件。最后一行显示最终选择。现在您必须编写连接脚本。
Path = Pick Directory( "Select Analytics Data Directory" );
Files_All = Files In Directory( Path );
NFS_All = N Items( Files_All );
Files = {};
//Remove non-text files
For( f = 1, f < NFS_All + 1, f++,
If( Contains( Files_All[f], ".txt" ) > 0,
Insert Into( Files, Files_All[f] )
)
);
//Prompt to select individual files
List_NPr = {};
List_Pr = Files;
PromptF = New Window( "File Selection",
<<MODAL>>>> Remove Selected >>>>",
List_NPr = Concat( List_NPr, Pr << Get Selected );
List_Pr = Remove( List_Pr, Pr << Get Selected Indices );
Pr << Set Items( List_Pr );
NPr << Set Items( List_NPr );
FList = List_Pr;
)
),
Text Box( " " ),
V List Box(
Text Box( "Files Excluded:" ),
NPr = List Box( List_NPr, width( 350 ), nlines( 30 ) ),
Button Box( "<<<< Add Selected <<<<",
List_Pr = Concat( List_Pr, NPr << Get Selected );
List_NPr = Remove( List_NPr, NPr << Get Selected Indices );
Pr << Set Items( List_Pr );
NPr << Set Items( List_NPr );
FList = List_Pr;
)
)
)
)
);
Wait( 0 );
Files = List_Pr;
NFS = N Items( Files );
show(FList);</MODAL>