파일 열기, 열 이름 변경 및 원래 형식으로 저장하는 루프모두들 안녕,
일련의 파일(.dx)을 열고 각 파일의 열 중 하나에서 텍스트를 변경하는 스크립트를 조합해 보았습니다. 하나 또는 두 개의 파일에 대해 개별적으로 작동하도록 관리하지만 4개의 세트를 시도하면 무한 루프가 시작됩니다. 아무도 도와 주시겠습니까? 문제가 파일에 있을 가능성이 있지만 jsl의 초보자이기 때문에 먼저 스크립트를 조사하고 싶습니다. 이상적으로는 파일을 jmp가 아니라 dx로도 저장하고 싶습니다.
Files = Pick File( "Select File(s)", "G:\Retention Compliant\Research\Analytical\Projects\IR database", {"All Files|*"}, 1, 0, "", "multiple" );
For( i = 1, i <= N Items( Files ), i++,
Try( dt = Open( Files[i], "text" ) );
wait( 0 );
For( n = 1, n <= N Items (Files), n++,
colList = dt << get column names( character, string );
For( i = 1, i <= N Items( colList ), i++,
selRows = dt << get rows where(
Column( dt, colList[i] )[Row()] == "##YUNITS= % Transmittance" | Column( dt, colList[i] )[Row()] == "##YUNITS= % T"
);
If( N Rows( selRows ) > 0,
Column( dt, colList[i] )[selRows] = "##YUNITS= % T";
);
);
) );스크립팅Re: 파일 열기, 열 이름 변경 및 원래 형식으로 저장하는 루프내가 찾은 문제로 아래 스크립트에 주석을 달았습니다..dx 파일에서 읽을 수 있다는 것에 놀랐습니다.JMP는 확실히 .dx 파일 쓰기를 지원하지 않습니다(제가 아는 한).
Files = Pick File(
"Select File(s)",
"G:\Retention Compliant\Research\Analytical\Projects\IR database",
{"All Files|*"},
1,
0,
"",
"multiple"
);
For( i = 1, i <= N Items( Files ), i++,
// Open one file
Try( dt = Open( Files[i], "text" ) );
Wait( 0 );
// Loop from 1 to the number of files (even though only 1 file has been opened)
For( n = 1, n <= N Items( Files ), n++,
// Here you will be reading the column names in for the first file over and over
colList = dt << get column names( character, string );
// Loop using "i" as the index across all of the columns....in the first file
// since that is all we have read in.....but since you are using "i", you will
// be creating an infinate loop, since you are using "i" for the first loop
// and you will be interferring with the assumed stepping for the outter loop
For( i = 1, i <= N Items( colList ), i++,
selRows = dt << get rows where(
// You are not in a formula, so the Row() function will not provide a predictable result
Column( dt, colList[i] )[Row()] == "##YUNITS= % Transmittance" | Column( dt, colList[i] )[Row()] ==
"##YUNITS= % T"
);
If( N Rows( selRows ) > 0,
Column( dt, colList[i] )[selRows] = "##YUNITS= % T"
);
);
);
);Re: 파일 열기, 열 이름 변경 및 원래 형식으로 저장하는 루프dx가 무엇인지 확실하지 않지만 .csv 확장자로 저장할 수 있으며 아마 비슷할 것입니다.
Re: 파일 열기, 열 이름 변경 및 원래 형식으로 저장하는 루프Craige에게 감사드립니다. 이제 모든 파일에서 오류 없이 작동합니다! 원본 형식(.dx)으로 저장하고 가급적이면 파일 이름을 유지하는 방법에 대한 아이디어가 있으십니까?
Re: 파일 열기, 열 이름 변경 및 원래 형식으로 저장하는 루프1) 편집기 오른쪽 클릭 팝업을 사용하여 JSL을 다시 포맷합니다. 둥지를 더 잘 볼 수 있습니다.
2) 내부 루프에서 i 변수를 재사용하고 있습니다. 루프가 발생합니다.
3) try() 래퍼를 제거하거나 오류를 포착할 때 무언가를 수행하도록 합니다.