Jmp로 데이터 가져오기안녕,
주기적 데이터에 대한 JMP 분석을 개발 중입니다. 매주 특정 폴더에 새로운 CSV를 생성하는 Excel 매크로가 있습니다. 저는 아직 JMP를 아주 기초적으로 사용하고 있기 때문에 이 활동을 수행하기 위한 스크립트를 작성하는 데 도움이 되는 커뮤니티의 지원을 받지 못했습니다. 나는 주변을 검색하려고 노력했지만 해결책을 찾지 못했습니다. CSV 파일에는 헤더가 포함된 19개의 열이 있습니다. 문제가 발생하면 CSV에서 헤더 행을 제거할 수 있습니다. 데이터를 평가할 수 있는 다른 스크립트를 실행할 수 있도록 파일을 JMP의 상위 데이터 테이블로 자동으로 가져오는 데 도움이 되는 스크립트용 코드 솔루션에 대해 도움을 줄 수 있는 사람이 있나요?
Re: Jmp로 데이터 가져오기txnelson님 답변 감사드립니다. 이는 "집계된 온라인 추세 데이터"에 대한 로그 파일에 있는 내용입니다. (이것은 스크립트를 실행할 때 열리는 파일입니다)
/*:
//:*/
// This script will concatenate cleaned online data files from APPLIKON controllers to a master table.
// Define function to open .xlsx files
DataUpdate = Function({filepath},
Open(
filepath,
Worksheets( "Data" ),
Use for all sheets( 0 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
)
);
//Define path to where .xlsx files are stored (location where this script is stored)
path = get default directory();
//Open Running Table (Online Trend Data Aggregated.jmp) - assuming in same directory as .xlsx files (could change path to wherever)
dt_running = Open(path||"Online Trend Data Aggregated.jmp");
//Get List of Files in Directory
files = Files In Directory(path);
//Remove any files from the list that are not .xlsx or do not contain "APPLIKON" in file name
for(i=N Items(files),i>=1,i--,
If(contains(files[i],".xlsx") == 0 | contains(files[i],"APPLIKON") == 0, Remove From(files,i));
);
//Get max(File Date) in running table to determine which files need to be appended
max_date = max(dt_running:File Date << Get Values);
//Extract Dates from File Names and determine if date is > max_date from running table
dates = {};
update_files = {};
for(i=1, i<=N Items(files),i++,
word_list = Words(files[i],"-"); //breaks out file name into words delimited by hyphens
temp_date = informat(trim(word_list[1]||"/"||word_list[2]||"/"||word_list[3]),"m/d/y"); //first 3 words are month, day, year - concatenat them separated by "/"
if(temp_date > max_date,
Insert Into(dates,temp_date);
Insert Into(update_files,files[i])
)
);
//Import selected files, add File Date column, and concatenate to running table
for(i=1,i<=N Items(update_files),i++,
dt_temp = DataUpdate(path||update_files[i]);
dt_temp << New Column("File Date", format("m/d/y"), Set Values(J(N Row(dt_temp),1,dates[i])));
dt_temp << Go To(:File Date) << Move Selected Column(To first);
dt_running << Concatenate( dt_temp, Append to First Table(1));
Close(dt_temp,nosave);
);
dt_running << Clear Column Selection;
/*:
Scriptable[]Re: Jmp로 데이터 가져오기디버거를 사용하지 않고 파일을 실행하면 로그에 어떤 내용이 표시됩니까?Re: Jmp로 데이터 가져오기안녕하세요,
원래 포스터와 같은 해결 방법을 찾고 있어요!
해당 스크립트를 복사하고 필요에 맞게 수정했습니다(원래 솔루션이 제시하는 것 대신 JMP 자체에서 가져오기 스크립트를 복사하여 붙여넣으라는 위의 제안 포함).
...하지만 어떤 이유에서인지 작동하지 않습니다.
스크립트는 JMP 파일 "Online Trend Data Aggregated"를 연 다음 중지하고 아무 작업도 수행하지 않습니다. 그 후에는 무슨 일이 일어날까요?
디버거는 전체 작업을 실행하며 내가 받는 유일한 메시지는 오른쪽 상단에 "프로그램 실행이 종료되었습니다"라는 메시지뿐입니다.
어떤 통찰력이라도 높이 평가됩니다. 아래 스크립트:
// This script will concatenate cleaned online data files from APPLIKON controllers to a master table.
// Define function to open .xlsx files
DataUpdate = Function({filepath},
Open(
filepath,
Worksheets( "Data" ),
Use for all sheets( 0 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
)
);
//Define path to where .xlsx files are stored (location where this script is stored on a network drive)
path = get default directory();
//Open Running Table (Online Trend Data Aggregated.jmp) - assuming in same directory as .xlsx files (could change path to wherever)
dt_running = Open(path||"Online Trend Data Aggregated.jmp");
//Get List of Files in Directory
files = Files In Directory(path);
//Remove any files from the list that are not .xlsx or do not contain "APPLIKON" in file name
for(i=N Items(files),i>=1,i--,
If(contains(files[i],".xlsx") == 0 | contains(files[i],"APPLIKON") == 0, Remove From(files,i));
);
//Get max(File Date) in running table to determine which files need to be appended
max_date = max(dt_running:File Date << Get Values);
//Extract Dates from File Names and determine if date is > max_date from running table
dates = {};
update_files = {};
for(i=1, i<=N Items(files),i++,
word_list = Words(files[i],"-"); //breaks out file name into words delimited by hyphens
temp_date = informat(trim(word_list[1]||"/"||word_list[2]||"/"||word_list[3]),"m/d/y"); //first 3 words are month, day, year - concatenat them separated by "/"
if(temp_date > max_date,
Insert Into(dates,temp_date);
Insert Into(update_files,files[i])
)
);
//Import selected files, add File Date column, and concatenate to running table
for(i=1,i<=N Items(update_files),i++,
dt_temp = DataUpdate(path||update_files[i]);
dt_temp << New Column("File Date", format("m/d/y"), Set Values(J(N Row(dt_temp),1,dates[i])));
dt_temp << Go To(:File Date) << Move Selected Column(To first);
dt_running << Concatenate( dt_temp, Append to First Table(1));
Close(dt_temp,nosave);
);
dt_running << Clear Column Selection;
Re: Jmp로 데이터 가져오기@cwillden
이것은 정말 매력적이었습니다. 여러분의 지원에 진심으로 감사드립니다. 이를 통해 고유한 CSV 파일에 있는 수십만 개의 행을 몇 초 만에 처리할 수 있었습니다. 감사합니다!!!Re: Jmp로 데이터 가져오기다음은 이를 수행하는 방법에 대한 예입니다.CSV 파일에 X1과 X2라는 2개의 열이 있다고 가정해 보겠습니다.2개의 샘플 csv 파일("3-29-18 - My Data.csv" 및 "4-5-18 - My Data.csv")을 만듭니다.또한 CSV 파일과 동일한 디렉터리에 저장한 실행 중인 jmp 테이블도 있습니다.
다음 스크립트는 디렉터리에서 모든 파일을 찾고, CSV가 아닌 파일과 파일 이름에 "내 데이터"가 없는 파일을 필터링합니다.그런 다음 이미 실행 중인 테이블로 가져온 파일의 가장 최근 날짜를 가져옵니다.그런 다음 이전 기준을 충족하는 파일 목록을 반복하여 파일 이름에서 날짜를 추출합니다.날짜가 실행 중인 테이블의 최대 날짜보다 크면 실행 중인 테이블에 추가할 파일 목록에 해당 파일을 넣습니다.
그런 다음 추가해야 한다고 판단한 파일을 먼저 열고 파일 날짜 열을 추가한 다음 파일을 실행 중인 테이블에 연결하여 반복합니다.
//Define function to open up your CSV files - will need to be modified for your own CSV file
MyCSVImporter = Function({filepath},
Open(
filepath,
columns(
New Column( "X1", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "X2", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
)
);
//Define path to where csv files are stored
path = "$DOCUMENTS/temp/";
//Open Running Table (RunningTable.jmp) - assuming in same directory as CSV files (could change path to wherever)
dt_running = Open(path||"RunningTable.jmp");
//Get List of Files in Directory
files = Files In Directory(path);
//Remove any files from the list that are not .csv or do not contain "My Data" in file name
for(i=N Items(files),i>=1,i--,
If(contains(files[i],".csv") == 0 | contains(files[i],"My Data") == 0, Remove From(files,i));
);
//Get max(File Date) in running table to determine which files need to be appended
max_date = max(dt_running:File Date << Get Values);
//Extract Dates from File Names and determine if date is > max_date from running table
dates = {};
update_files = {};
for(i=1, i<=N Items(files),i++,
word_list = Words(files[i],"-"); //breaks out file name into words delimited by hyphens
temp_date = informat(trim(word_list[1]||"/"||word_list[2]||"/"||word_list[3]),"m/d/y"); //first 3 words are month, day, year - concatenat them separated by "/"<BR />
if(temp_date > max_date,
Insert Into(dates,temp_date);
Insert Into(update_files,files[i])
)
);
<BR />//Import selected files, add File Date column, and concatenate to running table
for(i=1,i<=N Items(update_files),i++,
dt_temp = MyCSVImporter(path||update_files[i]);
dt_temp << New Column("File Date", format("m/d/y"), Set Values(J(N Row(dt_temp),1,dates[i])));
dt_temp << Go To(:File Date) << Move Selected Column(To first);
dt_running << Concatenate( dt_temp, Append to First Table(1));
Close(dt_temp,nosave);
);
dt_running << Clear Column Selection;
이 예에서 RunningTable에는 이미 3-29-18 데이터가 있으므로 4-5-18 데이터만 추가합니다.
Re: Jmp로 데이터 가져오기감사해요!
@uday_guntupalli 예, 데이터는 항상 동일한 형식, 동일한 수의 열 및 동일한 헤더를 갖습니다.
저는 이미 한 번 JMP로 데이터를 가져온 적이 있습니다. 문제는 생성될 새 CSV 파일에서 이 데이터를 매주 자동으로 업데이트하는 것입니다. 매주 " - My Data"라는 파일 이름으로 새 CSV 파일이 생성됩니다. 저는 JMP가 매번 이 데이터를 상위 파일로 가져오도록 하려고 합니다. JMP가 자동으로 폴더 디렉토리로 이동하여 목록에서 최신 파일을 선택하고 해당 데이터를 가져와서 실행 중인 테이블에 수정하도록 명령을 작성하는 방법은 무엇입니까?
Re: Jmp로 데이터 가져오기간단히 설명하자면 @uday_guntupalli 응답:
이와 같은 인터페이스를 제공할 것입니다. 가져오는 항목을 파악하고 사용자 정의할 수 있도록 "미리보기가 포함된 데이터"를 선택할 수 있습니다. 가져오기를 완료한 후 가져온 데이터 테이블로 이동합니다.데이터 테이블 표시 왼쪽에 있는 테이블 패널을 살펴보세요. "소스" 항목 앞의 녹색 삼각형을 마우스 오른쪽 버튼으로 클릭하면 JMP에서 생성된 스크립트를 볼 수 있는 "편집" 옵션이 제공됩니다.그런 다음 해당 스크립트를 잘라내어 주간 스크립트 개발의 시작 부분에 붙여넣을 수 있습니다.
Re: Jmp로 데이터 가져오기안녕 @NilD ,
처음 수동으로 가져올 수 있는 경우 JMP가 스크립트를 생성합니다.결과 테이블에는 JSL을 사용하여 데이터를 가져오는 방법을 정확하게 보여주는 "소스" 스크립트가 있습니다.
JMP가 .csv 파일을 올바르게 가져오지 못하는 경우 다음을 수행하십시오.평소와 같이 파일 > 열기(또는 Ctrl + O)를 수행하고(필요한 경우 데이터 파일 열기 창에서 파일 형식을 "텍스트 파일"로 변경) .csv 파일을 탐색하여 선택합니다..csv를 열기 전에 파일 열기에 대한 다양한 옵션을 제공하는 일부 라디오 버튼이 표시되어야 합니다.하나는 "미리보기가 포함된 데이터"입니다.이를 선택하면 데이터를 JMP로 가져오기 전에 가져오기 설정을 변경할 수 있습니다.

Re: Jmp로 데이터 가져오기@NilD ,
파일은 항상 같은 형식입니까? 즉, 동일한 열 이름과 동일한 유형의 데이터가 포함되어 있습니까?
가장 쉬운 방법은 JMP가 파일을 가져오기 위한 스크립트를 제공하도록 하는 것입니다. 그러면 선택 항목을 사용자 정의하고 스크립트를 재사용할 수 있습니다.
파일 ==> 열기 ==> 원하는 파일 선택
이와 같은 인터페이스를 제공할 것입니다. 가져오는 항목을 파악하고 사용자 정의할 수 있도록 "미리보기가 포함된 데이터"를 선택하는 것이 좋습니다. 완료한 후 녹색 삼각형을 클릭하면 JMP에서 생성된 스크립트를 볼 수 있는 "편집" 옵션이 제공됩니다.
