열이 3 개인 테이블이 있다고 가정 해 보겠습니다 (아래 예). 3 개의 열을 모두 포함하는 "도시 코드"열로 테이블의 하위 집합을 만듭니다.
| 도시 코드 | 등록 번호 | 등록 날짜 |
| 032 | 0320537648 | 20201026 |
| 160 | 1600084082 | 20201020 |
| 281 | 2821162566 | 20201020 |
| 325 | 3250488500 | 20201024 |
| 420 | 4200618843 | 20201101 |
| 511 | 5110680174 | 20201027 |
| 720 | 7200054737 | 20200825 |
다음과 같이 하위 집합 파일 만 텍스트 파일로 저장하고 싶습니다. city code value.txt
포럼에서 파일을 텍스트 파일로 저장하는 데 매우 도움이되는 다음 jsl 스크립트를 찾았습니다. 문제는 파일이 도시 코드 = value.txt로 저장된다는 것입니다.
기본 데이터 테이블도 텍스트 파일로 저장되어 있습니다.
//Save as txt file
openDTs = {};
For( i = 1, i <= N Table(), i++,
Insert Into( openDTs, Data Table( i ) )
);
For( i = 1, i <= N Items( openDTs ), i++,
one_name = openDTS[i] << get name;
file_path = one_name || ".txt";
openDTS[i] << Save(file_path);
);
저는 JMP와 스크립팅에 익숙하지 않으므로 어떤 아이디어라도 대단히 감사합니다.
다음은 제공 한 예제 데이터 테이블을 만드는 스크립트입니다.그런 다음 하위 집합을 만들고 각 하위 집합을 .txt 파일로 저장합니다.
이 예제를 실행하기 위해해야 할 일은 코드 줄을 변경하는 것입니다.
saveFolder = "C:\xxxxxxxxxxxxx\";
파일을 저장할 폴더의 실제 경로를 지정한 다음 코드를 실행하십시오.
Names Default To Here( 1 );
// Create the example data table
New Table( "Example",
Add Rows( 7 ),
New Column( "City code", Numeric, "Continuous", Format( "Best", 12 ), Set Selected, Set Values( [32, 160, 281, 325, 420, 511, 720] ) ),
New Column( "Registration Number",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [320537648, 1600084082, 2821162566, 3250488500, 4200618843, 5110680174, 7200054737] )
),
New Column( "Registration Date",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [20201026, 20201020, 20201020, 20201024, 20201101, 20201027, 20200825] )
)
);
// Here is the real code.....just change the saveFolder = to the actual folder you want to
// save the files to
dt = Current Data Table();
// Create the subsets
dtSub = dt << Subset( By( :City code ),
All rows, Selected columns only( 0 ),
columns( :Registration Number, :Registration Date ) );
saveFolder = "C:\xxxxxxxxxxxxx\";
For( i = 1, i <= N Items( dtSub ), i++,
// Given the structure of the data tables created with a Subset using a By() clause
// City Code = 32
// the Word() function retuns the "32" and it is added as the name of the file to save
dtSub[i] << Save( saveFolder || Word( -1, dtSub[i] << get name, "=" ) || ".txt" )
);
헉헉 정말 고맙습니다! 매력처럼 작동했습니다.