zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加しますやあ、
テーブルを作成してからzipフォルダーを開き、最初にログファイルを特定のパスに保存し、次にファイル(長いテキストファイル)を読み取り、文字列が含まれているかどうかを確認しました。 「はい」の場合、作成されたテーブルに新しい行を追加し、値を追加します。新しい行と値をテーブルに追加するまではすべて機能します。 ログにエラーや情報がないため、何が問題なのかわかりません。 以下は私のスクリプトです。誰かが問題の内容を提案していただけますか?
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();
);
);
自動化とスクリプト作成Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します問題が見つかったと思います。 {} が必要です。 以前は {} なしで動作していました。 なぜ今 {} が必要なのか、分かる人はいるでしょうか?
dt2 << add rows ({t1 = lst2[k], data = "Yes"}),
dt2 << add rows ({t1 = lst2[k], data = "No"})
Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します
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 Indexヘルプ -> スクリプトインデックス
このドキュメントは、少なくとも JMP 14 以降はこのようになっています。 バージョン間で動作に変化が見られますか?
Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加しますこんにちは、クレイジさん
列の1つに行と値を追加するだけで、以下を実行して成功しました。
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: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加しますlst2[k] が数値 (おそらく 1) だった場合、それがどのように機能しているかがわかります。 (古い) 現在の行の t1 を変更して割り当てが評価され、その結果 (t1 内の) が追加する行の数になります。ただし、これらの行には、次回ループが実行されるまで値が割り当てられません。 しかし、それはあなたが持っているもの(キャラクターt1)と完全に一致しないので、おそらくそうではありません。
理解できてよかったです。リストはリスト内の項目を評価しません。 代わりに、リストは add rows メソッドに渡され、addrows は新しく追加された行のリストを使用します。
Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します上記の元のスクリプトの try() と throw() について次のような質問があります。 try() + throw() がスキップされず、ループの次の処理に続行されない状況が発生しました。 この問題は、line.log の読み取り時に発生します。 line.log の 1 つが大きすぎて開けません。 特定の line.log を手動で開こうとしたところ、ファイルが大きすぎて txt で開けないというエラーが表示されたため、このように結論付けました。 そこで、別の try() と throw() を追加しましたが、それでも、lst2[k]「読み取ることができません」と lst2[k[ 「開くのに失敗しました」というメッセージが出力されるだけでした。その後、ループはその lst2[k] で停止し、次のループには進みません。 try()と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: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します構造を確認するためにコードを再フォーマットしました (control-M)。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,<
おそらく外投げも望まないでしょう。 場合によっては、そのように throw() を使用することが望ましい場合があります。例外の処理がまだ完了しておらず、例外を含むハンドラーに伝播させたいということを本当に意味する場合ですが、少なくとも内部の試行については、それを処理したと思います。ループして続行します。
Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します内部の throw() のみを削除すると、スクリプト出力はすべて lst2[k] が「読み取れません」になります。 ただし、内側と外側の両方の throw() を削除すると、スクリプトは設計どおりに実行されます。
Re: zip ファイルを読み取り、「文字列」が含まれている場合は、値ラベルを持つテーブルに行を追加します答えはあると思いますが、明確にしておきます。
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
)
);