For 루프의 증분 변수 이름을 목록에 저장나는 노력하고있다
1) Unique_Files 목록에 나열된 일련의 파일을 엽니다.
2) 파일이 존재하지 않으면 파일이 존재한다는 메시지가 표시된 대화 상자가 열립니다.
3) 파일이 있으면 JMP에서 파일을 엽니다.
4) 파일이 존재하는 경우 데이터 테이블 참조 이름을 UniqueTables 목록에 추가합니다.
내 스크립트의 다른 모든 부분은 데이터 테이블 참조 이름 목록을 생성할 수 있는 기능을 제외하고는 작동하는 것 같습니다.아래에 내 스크립트가 작성된 방식이 목록에 표시됩니다.
UniqueTables = { DataTable("파일 이름1"), 데이터 테이블("파일 이름2"),...}
대신 스크립트가 다음과 같이 목록을 생성하기를 원합니다.
고유 테이블 = My_Table_1, My_Table_2, My_Table_3,...
미리 감사드립니다.
N Items (Unique_Files);
UniqueTables = { };
For ( i = 1, i <= N, i ++,
If(
File Exists( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv"),
Eval(
Substitute(
Expr(
MyTab = Open( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv");
Insert Into( UniqueTables, MyTab)
),
Expr( MyTab),
Parse( My_Table_" ||Char(i))
)
),
New Window ("File Not Found",
<< Modal,
V List Box(
Text Box( Unique_Files[i]|| " does not exist in folder."),
Button Box( "OK")
)
)
)
);Re: For 루프의 증분된 변수 이름을 목록에 저장예
Re: For 루프의 증분된 변수 이름을 목록에 저장보기 힘든 그 시절!!!!
Re: For 루프의 증분된 변수 이름을 목록에 저장마침표 "." 후에 끝났다
Show( UniqueTables );.
따라서 이를 제거하면 정상적으로 작동할 것입니다. 향후 참조를 위해 이전 예제를 수정하겠습니다.
Re: For 루프의 증분된 변수 이름을 목록에 저장마지막 줄에서 다음 오류가 발생합니다.
예상치 못한 "UniqueTables". 아마도 ";"가 누락되었을 수 있습니다. 또는 ",".
42행 열 1: ►UniqueTables[1] << Concatenate( UniqueTables[2] );
무시된 나머지 텍스트는 다음과 같습니다.
UniqueTables[1]<Re: For 루프의 증분된 변수 이름을 목록에 저장
당신은 다양한 구조가 실제로 당신에게 무엇을 제공하는지에 대한 지식이 부족한 것 같습니다.시간을 내어 스크립팅 가이드를 읽어 보시기 바랍니다.그러나 아래 내용을 통해 현재 코드의 일부 문제를 해결할 수도 있다고 생각합니다.아래에 주석이 달린 코드를 살펴보고 현재 겪고 있는 문제에 대한 정보를 추가하는지 확인하세요.
names default to here(1);
dt1=open("$SAMPLE_DATA/big class.jmp");
dt2=open("$SAMPLE_DATA/big class families.jmp");
// Here is what the value of dt1 is
show(dt1);
// From the log
// dt1 = DataTable("big class");
// Therefore the value of dt2 is,
show(dt2);
// dt2 = DataTable("big class families");
// The structure of the Concatenate Platform syntax is:
// data table("data table name") << Concatenate( data table("data table2 name"), data table("data table2 name") );
// That would mean that the following will concatenate our two files
data table( "big class" ) << Concatenate( data table( "big class families" ) );
// It also means, that since we have variables dt1, which was shown to equal Data Table( "big class" ), and
// dt2 which has the value of Data Table( "big class families" )
// the above concatenate statement can be written
dt1 << Concatenate( dt2 );
// Here is another way to do this
UniqueTables = {};
MyTab = open("$SAMPLE_DATA/big class.jmp");
insert into( UniqueTables, MyTab );
MyTab = open("$SAMPLE_DATA/big class families.jmp");
insert into( UniqueTables, MyTab );
Show( UniqueTables );
// returns
// UniqueTables = {DataTable("big class"), DataTable("big class families")};
// So now the Concatenate statement can be written
UniqueTables[1] << Concatenate( UniqueTables[2] );Re: For 루프의 증분된 변수 이름을 목록에 저장무엇인지 확인해보세요 XY 문제 즉, 우리가 당신을 돕는 데 확실히 도움이 될 것입니다.
하지만 그 외에는.당신이 하려는 것이 폴더에 있는 모든 JMP 파일을 함께 연결하는 것뿐입니다.
Names default to here( 1 );
// this is just creating an example set don't worry about it.
dt = open("$SAMPLE_DATA\Big Class.jmp");
dir = convert file path("$DESKTOP\Example\");
Create Directory(dir);
for(i=1, i<=6, i++,
path = convert file path(char(i)||".jmp", base(dir));
dt << Save As(path);
);
// this is actually what you'll want to run
dir = convert file path("$DESKTOP\Example\");
// find the files in that directory
files = files in directory(dir);
// create a base table
dt_final = New Table("Concatted");
for(i=1, i<=nitems(files), i++,
dt = open(convert file path(files[i], base(dir)));
dt_final << Concatenate(dt, append to first table(1));
close(dt, no save);
)Re: For 루프의 증분된 변수 이름을 목록에 저장안녕하세요 짐,
불행히도 내 상황을 어떻게 설명했는지 명확하지 않았기 때문에 여전히 원하는 결과를 얻지 못했습니다.
Unique_Files 목록이 폴더 위치에 저장된 CSV의 파일 이름임을 지정했어야 했습니다.
Unique_Files = {"FileName1", "FileName2", "FileName3", etc...}
<< 이름 가져오기 함수를 사용하면 UniqueTables 목록이 다음과 같이 생성됩니다.
UniqueTables = {"FileName1", "FileName2", "FileName3", etc...}
내가 찾고 있을 때
UniqueTables = {My_Table_1, My_Table_2, My_Table_3, etc...}
해당 형식으로 UniqueTables 목록을 모은 후 내 계획은 해당 테이블 중 일부를 연결하고 연결된 원본 테이블을 닫는 것이었습니다.저는 My_Table_1이라는 테이블 참조 이름으로 이 작업을 수행하는 방법만 알고 있습니다. 파일 이름 "FileName1"에서 테이블을 연결하는 방법이 있습니까?그렇다면 이 문제를 완전히 우회할 수 있습니다.
미리 감사드립니다!당신은 매우 도움이 되었습니다.
Re: For 루프의 증분된 변수 이름을 목록에 저장왜 이 일을 하고 싶은지 물어봐도 될까요?이렇게 하면 변수 이름을 찾을 수 없기 때문에 스크립트 지원이 매우 어려워집니다. 소유자가 더 이상 자신의 코드를 이해할 수 없게 되면 스크립트를 수정하는데, 이는 항상 제가 겪는 문제입니다.
여러 변수를 제공하면 목록에는 제공되지 않는 무엇을 제공합니까?
불필요해 보이기 때문에
UniqueTables[1] = My_Table_1 = DataTable("filename1");
Re: For 루프의 증분된 변수 이름을 목록에 저장데이터 테이블 참조에서 테이블 이름을 검색하기만 하면 되므로 "Mytab"에 대한 참조를 다음과 같이 변경합니다.
Insert Into( UniqueTables, MyTab << get name)
JSL의 다양한 요소에 대한 모든 메시지는 스크립팅 가이드에 문서화되어 있습니다.
도움말==>스크립팅 가이드