Compruebe si hay una cadena en un archivo antes de unir tablas.Abro 2 archivos de Excel. Estoy tratando de unir tablas solo si la lista contiene opciones. ¿Cómo logro esto?
//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: Verifique una cadena en un archivo antes de unir tablas.¡Funciona perfectamente!
Gracias una tonelada
Re: Verifique una cadena en un archivo antes de unir tablas.¿Es esto lo que estás buscando? Si no, entonces no estoy obteniendo lo que buscas
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: Verifique una cadena en un archivo antes de unir tablas.Gracias por la respuesta. No expliqué bien el problema. Lo siento por eso.
El archivo de volumen es dinámico. Si la variable de elección está presente en el archivo de lista, debo unirme a las tablas de Volumen y Lista. Si no uso la tabla de Volumen como es para futuras manipulaciones. He adjuntado los 3 archivos. un buen rato.
Cualquier ayuda apreciada.
Re: Verifique una cadena en un archivo antes de unir tablas.Creo que el siguiente script te acercará más a lo que quieres. No tengo el formato de su variable "Elección", así que realmente no pude probar el código, pero creo que le proporcionará un método que le dará lo que quiere
//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" )
);