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 파일을 읽고 "문자열"이 포함된 경우 값 레이블이 있는 테이블에 행을 추가합니다.안녕 크레이지,
열 중 하나에 행과 값만 추가하면 아래에서 성공했습니다.
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)과 잘 맞지 않으므로 아닐 수도 있습니다.
알아내서 다행입니다. 목록은 목록의 항목을 평가하지 않습니다. 대신 목록이 행 추가 메서드로 전달되고 addrows는 새로 추가된 행의 목록을 사용합니다.
Re: zip 파일을 읽고 "문자열"이 포함된 경우 값 레이블이 있는 테이블에 행을 추가합니다.위의 원래 스크립트에서 try() 및 throw()에 대한 다음 질문이 하나 있습니다. try() + throw()가 건너뛰지 않고 다음 루프로 계속되는 상황이 발생합니다. 이 문제는 line.log를 읽을 때 발생합니다. line.log 중 하나는 너무 커서 열 수 없습니다. 나는 특정 line.log를 수동으로 열려고 시도했기 때문에 그렇게 결론을 내렸고 파일이 너무 커서 txt로 열 수 없다는 오류가 발생했습니다. 그래서 또 다른 try() 및 throw()를 추가했지만 여전히 lst2[k]"cannot read" 및 lst2[k[ "fail to open" 메시지만 인쇄했습니다. 그런 다음 루프는 해당 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] "cannot read"가 됩니다. 그러나 내부 및 외부 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
)
);