lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorHola,
Creé una tabla, luego abrí una carpeta zip, primero guardé un archivo de registro en una ruta específica, luego leí un archivo (archivo de texto largo) y luego verifiqué si contiene una cadena. en caso afirmativo, agregue una nueva fila a la tabla creada y agregue valor. todo funciona hasta que se agrega una nueva fila y valor a la tabla. No puedo averiguar cuál es el problema porque no hay ningún error o información en el registro. A continuación se muestra mi secuencia de comandos, ¿alguien puede sugerir cuál es el problema?
dt = open(sometable);
lst2 = column(dt1, "t1") << Get Values;
dt2 = new table("data_"||todaydate,
new column("t1", character),
newcolumn("data", character)
);
for (k=1, k <=N items(lst2), k++,
//print (lst2[k]);
Try(
za = open(path2||lst2[k], zip);
dirlist = za << dir;
//show(dirlist); //check the list
for (l=1, l<=N Items(dirlist), l++,
If (Left(dirlist[l],5) == "tests" & Right(dirlist[l],8) == "_raw.log" ,
show(dirlist[l]);
text = za << read(dirlist[l]);
//print (dirlist[l]);
save text file(path1|| Format Date( Today(), "ddmonyyyy" ) ||"\"||lst2[k]||"_"||dirlist[l],text);
,
dirlist[l]== "line.log" ,
text = za << read(dirlist[l]);
if(contains(text, "string"),
dt2 << add rows (t1 = lst2[k], data = "Yes"),
dt2 << add rows (t1 = lst2[k], data = "No")
);
);
)
,
print (lst2[k] || "fail to open");
Throw();
);
);
Automatización y secuencias de comandosRe: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorCreo que encontré el problema. Necesita el {} . Funcionó sin {} antes. ¿Alguien tiene una idea de por qué ahora necesita el {}?
dt2 << add rows ({t1 = lst2[k], data = "Yes"}),
dt2 << add rows ({t1 = lst2[k], data = "No"})
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valor
Help->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexHelp->Scripting IndexAyuda->Índice de secuencias de comandos
El documento ha sido así desde al menos JMP 14. ¿Estás viendo un cambio en el comportamiento entre versiones?
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorHola Craige,
Lo estaba haciendo a continuación y con éxito, cuando solo agregué filas y valor a una de las columnas.
dt2 = new table("data_"||todaydate,
new column("t1", character),
newcolumn("data", character)
);
for (k=1, k <=N items(lst2), k++,
dt2 << add rows (t1 = lst2[k])
);
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorSi lst2[k] fuera un número, tal vez 1, puedo ver cómo podría haber parecido funcionar. La asignación sería evaluada, cambiando t1 de la (antigua) fila actual, luego el resultado (en t1) sería el número de filas a agregar. Pero a esas filas no se les asignará un valor hasta la próxima vez que pasen por el bucle. Pero eso no encaja del todo con lo que tienes (un carácter t1), así que tal vez no.
Me alegro de que lo hayas resuelto; la lista no evalúa los elementos de la lista. En su lugar, la lista se pasa al método de agregar filas y addrows usa la lista en la fila recién agregada.
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorTengo una siguiente pregunta sobre try() y throw() en mi script original anterior. Me encuentro con una situación en la que try() + throw() no se salta y continúa con el siguiente bucle. El problema ocurre al leer line.log. Uno de los line.log es tan grande que no se puede abrir. Concluí porque traté de abrir manualmente el archivo line.log específico y me dio un error que decía que el archivo es demasiado grande para abrirlo por txt. Así que agregó otro try() y throw() para él, pero aún así, solo imprimió el mensaje de lst2[k]"no se puede leer" y lst2[k["no se pudo abrir". entonces el bucle se detiene en ese lst2[k], sin pasar al siguiente bucle. ¿Cometí un error sobre cómo usar try() y throw()?
dt = open(sometable);
lst2 = column(dt1, "t1") << Get Values;
dt2 = new table("data_"||todaydate,
new column("t1", character),
newcolumn("data", character)
);
for (k=1, k <=N items(lst2), k++,
//print (lst2[k]);
Try(
za = open(path2||lst2[k], zip);
dirlist = za << dir;
//show(dirlist); //check the list
for (l=1, l<=N Items(dirlist), l++,
If (Left(dirlist[l],5) == "tests" & Right(dirlist[l],8) == "_raw.log" ,
show(dirlist[l]);
text = za << read(dirlist[l]);
//print (dirlist[l]);
save text file(path1|| Format Date( Today(), "ddmonyyyy" ) ||"\"||lst2[k]||"_"||dirlist[l],text);
,
dirlist[l]== "line.log" ,<BR />try(
text = za << read(dirlist[l]);
if(contains(text, "string"),
dt2 << add rows (t1 = lst2[k], data = "Yes"),
dt2 << add rows (t1 = lst2[k], data = "No")
);<BR />,<BR />print(lst2[k] || "cannot read");<BR />throw();<BR />);
);
)
,
print (lst2[k] || "fail to open");
Throw();
);
);Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorReformateé el código (control-M) para ver la estructura y creo que quieres omitir el lanzamiento ()
The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,The error from <<read was caught, then re-thrown to the outer try,Se detectó el error de <
Probablemente tampoco quieras el tiro exterior. A veces, es deseable usar throw () de esa manera, si realmente quiere decir que no ha terminado de manejar la excepción y quiere que se propague a un controlador contenedor, pero al menos para el intento interno, creo que lo ha solucionado y quiere que el bucle para continuar.
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorelimine solo el tiro interno () la secuencia de comandos genera todo lst2 [k] "no se puede leer". Sin embargo, si elimina los throw() internos y externos, la secuencia de comandos se ejecutará según lo diseñado.
Re: lea el archivo zip, si contiene "cadena", agregue una fila a una tabla con etiqueta de valorCreo que tienes la respuesta, solo para aclarar:
dt = Open( sometable );
lst2 = Column( dt1, "t1" ) << Get Values;
dt2 = New Table( "data_" || todaydate, New Column( "t1", character ), New Column( "data", character ) );
For( k = 1, k <= N Items( lst2 ), k++,
Try(
za = Open( path2 || lst2[k], zip );
dirlist = za << dir;
For( l = 1, l <= N Items( dirlist ), l++,
If( Left( dirlist[l], 5 ) == "tests" & Right( dirlist[l], 8 ) == "_raw.log",
Show( dirlist[l] );
text = za << read( dirlist[l] );
Save Text File( path1 || Format Date( Today(), "ddmonyyyy" ) || "\" || lst2[k] || "_" || dirlist[l], text );
,/*else if*/ dirlist[l] == "line.log",
Try(
text = za << read( dirlist[l] );
If( Contains( text, "string" ),
dt2 << add rows( t1 = lst2[k], data = "Yes" ),
dt2 << add rows( t1 = lst2[k], data = "No" )
);
,/* catch*/
Print( lst2[k] || "cannot read" );
Throw(); // this throw will end the for-L loop
);
);
);
,/*catch*/
Print( lst2[k] || "fail to open" );
Throw(); // this throw will end the for-K loop
)
);