在连接表之前检查文件中的字符串。我打开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" )
);