leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valoreCIAO,
Ho creato una tabella, quindi ho aperto una cartella zip, prima ho salvato un file di registro in un percorso specifico, in secondo luogo ho letto un file (file di testo lungo), quindi ho controllato se contiene una stringa. in caso affermativo, aggiungi una nuova riga alla tabella creata e aggiungi valore. tutto funziona fino all'aggiunta di una nuova riga e valore alla tabella. Non riesco a capire qual è il problema perché non ci sono errori o informazioni nel registro. Di seguito è riportato il mio script, qualcuno può dare un suggerimento qual è il 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();
);
);
Automazione e scriptingRi: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valorePenso di aver trovato il problema. Hai bisogno di {} . Ha funzionato senza {} prima. Qualcuno ha un'idea del motivo per cui ora è necessario il {}?
dt2 << add rows ({t1 = lst2[k], data = "Yes"}),
dt2 << add rows ({t1 = lst2[k], data = "No"})
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valore
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 IndexHelp->Scripting IndexAiuto->Indice script
Il documento è stato così almeno da JMP 14. Stai vedendo un cambiamento nel comportamento tra le versioni?
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valoreCiao Craig,
Stavo facendo sotto e successo, quando aggiungo solo righe e valore a una delle colonne.
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])
);
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valoreSe lst2[k] fosse un numero, forse 1, posso vedere come avrebbe potuto funzionare. L'assegnazione verrebbe valutata, cambiando t1 della (vecchia) currentrow, quindi il risultato (in t1) sarebbe il numero di righe da aggiungere. Ma a quelle righe non sarebbe stato assegnato un valore fino alla volta successiva nel ciclo. Ma questo non si adatta perfettamente a quello che hai (un carattere t1), quindi forse no.
Sono contento che tu l'abbia capito; l'elenco non valuta gli elementi nell'elenco. L'elenco viene invece passato al metodo add rows e addrows utilizza l'elenco sulla riga appena aggiunta.
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valoreHo una domanda seguente su try() e throw() nel mio script originale sopra. Incontro una situazione in cui try() + throw() non salta e continua al ciclo successivo. Il problema si verifica durante la lettura di line.log. Uno dei line.log è così grande che non può essere aperto. Ho concluso così perché ho provato ad aprire manualmente lo specifico line.log e mi ha dato un errore dicendo che il file è troppo grande per essere aperto da txt. Quindi ha aggiunto un altro try() e throw() per questo, ma ha stampato solo il messaggio di lst2[k]"cannot read" e lst2[k["fail to open". quindi il ciclo si ferma a quel lst2[k], non andando al ciclo successivo. Ho commesso un errore su come usare try() e 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();
);
);Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valoreHo riformattato il codice (control-M) per vedere la struttura e penso che tu voglia tralasciare il throw()
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,L'errore da <
Probabilmente non vuoi nemmeno il lancio esterno. A volte usare il throw() in questo modo è desiderabile, se intendi davvero che non hai finito di gestire l'eccezione e vuoi che si propaghi a un gestore contenitore, ma almeno per il tentativo interno penso che te ne sia preso cura e vuoi il ciclo per continuare.
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valorerimuovi solo inner throw() lo script produce tutto lst2[k] "impossibile leggere". Tuttavia, se rimuovi entrambi i throw() interni ed esterni, lo script viene eseguito come previsto.
Ri: leggi il file zip, se contiene "stringa", quindi aggiungi una riga a una tabella con un'etichetta di valorePenso che tu abbia la risposta, solo per chiarire:
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
)
);