從列表中連接多個表使用此處的腳本我可以從任何文件夾中獲取表的列表。我希望能夠從創建的列表中連接表。我希望用戶能夠選擇他/她可以加入哪些表,並預設要用於加入的列。
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>