Verifica la presenza di una stringa in un file prima di unire le tabelle.Apro 2 file excel. Sto cercando di unirmi alle tabelle solo se l'elenco contiene una scelta. Come posso ottenere questo?
//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" )
);
);
);
Ri: controllare una stringa in un file prima di unire le tabelle.Funziona perfettamente!
Grazie mille
Ri: controllare una stringa in un file prima di unire le tabelle.E 'questo quello che stai cercando? Altrimenti, allora non otterrò quello che cerchi
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>
Ri: controllare una stringa in un file prima di unire le tabelle.Grazie per la risposta. Non ho spiegato bene il problema. Scusami.
Il file di volume è dinamico.Se la variabile choice è presente nel file di elenco, ho bisogno di unire le tabelle Volume ed Elenco. Se non utilizzo la tabella Volume come è per ulteriori manipolazioni. Ho allegato tutti e 3 i file. un bel po '.
Qualsiasi aiuto apprezzato.
Ri: controllare una stringa in un file prima di unire le tabelle.Penso che lo script qui sotto ti avvicini a quello che vuoi. Non ho il formato della variabile "Choice", quindi non ho potuto testare il codice, ma penso che ti fornirà un metodo che ti farà ottenere ciò che desideri
//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" )
);