在連接表之前檢查文件中的字符串。我打開2個excel文件。我只是在列表中包含選項時嘗試連接表。我如何實現這一目標?
//Accept Product input from user and save it in a text file
R = Open("Choice.txt",
Labels(0),
Columns(
C = Character(12);
)
);
Choice = {};
Choice = R:C[1];
//Open master data list
U = Open("Volume.csv","invisible");
T = Open("List.csv","invisible");
dt = Current data table();
Column_List = dt << Get Column Names("String");
for(i = 1, i<= NItems(Column_List),i++,
if(contains(Choice,Column_List[i]),
U = Data Table( "Volume" ) <<
Join(
With( Data Table( "List" ) ),
Merge Same Name Columns,
By Matching Columns( :number = :number ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 ),
Output Table( "Joined_With_List" )
);
);
);
Re:在連接表之前檢查文件中的字符串。完美的工作!
萬分感謝
Re:在連接表之前檢查文件中的字符串。這是你想要的?如果沒有,那麼我沒有得到你想要的東西
Names Default To Here( 1 );
// Open comma separated files
dtList = Open( "<THE path="" to="" the="" list="" file="">\list.csv" );
dtVolume = Open( "<THE path="" to="" the="" volume="" file="">\volume.csv" );
// Read in the choice value
choice = Load Text File( "C:\Users\txjim\Documents\choice.txt" );
// Find out if choice is in the List data table and if so,
// join the tables. If not, then set the Volume data table
// to be the processing data table.
If( Contains( dtList:Company << get values, choice ),
dtProcess = dtVolume << Join(
With( dtList ),
Merge Same Name Columns,
Match Flag( 0 ),
By Matching Columns( :Product Type = :Product Type ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 ),
Output Table( "Process" )
),
dtProcess = dtVolume
);</THE></THE>
Re:在連接表之前檢查文件中的字符串。感謝您的回复。我沒有很好地解釋這個問題。請相信。
卷文件是動態的。如果列表文件中存在選擇變量,我需要加入Volume和List表。如果不是我使用Volume表進行進一步的操作。我已經附加了所有3個文件。遇到這個問題一段時間。
任何幫助讚賞。
Re:在連接表之前檢查文件中的字符串。我認為下面的腳本會讓你更接近你想要的。 我沒有你的“選擇”變量的格式,所以我無法真正測試代碼,但我認為它會為你提供一個方法,可以得到你想要的
//Accept Product input from user and save it in a text file
R = Open( "Choice.txt", Labels( 0 ), Columns( C = Character( 12 ) ) );
Choice = {};
Choice = R:C[1];
//Open master data list
U = Open( "Volume.csv", "invisible" );
T = Open( "List.csv", "invisible" );
// Delete columns from the List data table that are not
// found in the Choice memory variable
Column_List = T << Get Column Names( "String" );
For( i = 1, i <= N Items( Column_List ), i++,
If( Contains( Choice, Column_List[i] ) == 0,
T << Delete Columns( Column_Names[i] )
)
);
newU = U << Join(
With( T ),
Merge Same Name Columns,
By Matching Columns( :number = :number ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 ),
Output Table( "Joined_With_List" )
);