여러 개의 CSV 파일 요약JMP를 데이터베이스와 같은 약 400 개의 CSV 파일이있는 바탕 화면의 파일 폴더로 보내려면 어떻게해야합니까? 여러 개의 열을 만들고 파일 당 1 행의 요약 테이블을 만드시겠습니까? 이 작업은 개별적으로 수행 할 수 있지만 영원히 필요하며 자동화 할 스크립트를 개발할 수 있기를 희망했습니다.
제목 : Re : 여러 CSV 파일 요약당신은 틀린 ..... 실수를 붙잡기를위한 감사합니다
발견 한 실수를 바로 잡기 위해 원래 항목을 수정했습니다.
제목 : Re : 여러 CSV 파일 요약데이터 테이블 대신 요약 테이블을 추가한다고 생각하십니까?
Names Default To Here( 1 );
dir = Pick Directory();
files = Files In Directory( dir );
dt = New Table( "concat", New Column( "File", character ) );
For( i = 1, i <= N Items( files ), i++,
If( Ends With( files[i], "csv" ), //just a check to make sure it's a csv
// Open the file
dt1 = Open( dir || files[i] );
//Get all of the numeric columns from the just opened file
thecolumns = dt1 << get column names( numeric );
// Create an output table of one row that contains the summary
// As many stats as desired can be added to the below to get all of the
// ones that are needed
dt1 << Summary( Mean( Eval( thecolumns ) ), Freq( "None" ), Weight( "None" ), output table name("tmpdt"));
// Add the summary table to the summary table
dt << concatenate( Data Table("tmpdt"), append to first table );
// Since what is wanted is the ID, not the file name, and the ID is
// the Sheeet name in the Excel spreadsheet, one has to get that value
// the the name of the data table, since that is where JMP 13 places the
// sheet name
dt:File[N Rows( dt ) ] = dt1 << Get Name;
// Close the no longer needed raw data table
Close( dt1, no save );
)
);제목 : Re : 여러 CSV 파일 요약필요한 스크립트에 대한 필자의 의견입니다. 그것은 매우 간단하며 모든 숫자 열을 요약하고 Excel 시트 이름을 새 열로 가져옵니다.
아래는 다음 답장에서 발견 된 문제를 기반으로 편집됩니다.
Names Default To Here( 1 );
dir = Pick Directory();
files = Files In Directory( dir );
dt = New Table( "concat", New Column( "File", character ) );
For( i = 1, i <= N Items( files ), i++,
If( Ends With( files[i], "csv" ), //just a check to make sure it's a csv
// Open the file
dt1 = Open( dir || files[i], private );
//Get all of the numeric columns from the just opened file
thecolumns = dt1 << get column names( numeric );
// Create an output table of one row that contains the summary
// As many stats as desired can be added to the below to get all of the
// ones that are needed
dt2 = dt1 << Summary( Mean( Eval( thecolumns ) ), Freq( "None" ), Weight( "None" ) );
// Add the summary table to the summary table
dt << concatenate( dt2, append to first table );
// Since what is wanted is the ID, not the file name, and the ID is
// the Sheeet name in the Excel spreadsheet, one has to get that value
// the the name of the data table, since that is where JMP 13 places the
// sheet name
dt:File[N Rows( dt ) ] = dt1 << Get Name;
// Close the no longer needed raw data table
Close( dt1, no save );Close( dt2, no save );
)
);
제목 : Re : 여러 CSV 파일 요약Vince의 응답에 대한 변형이 있습니다. 이렇게하면 각 파일에 다른 열 이름을 사용할 수 있습니다.
Names Default to here(1);
dir = pick directory();
files = files in directory(dir);
//table to hold summary data
dts = New Table("Summary", New Column("filename", character));
for(i=1, i<=nitems(files), i++, //for each filename
if(endswith(files[i], "csv"), //if file is a csv
//open the file
dt1 = open( dir||files[i], private );
//add a row to the summary table
dts << Add Rows(1);
//save the filename to the data table
Column( dts, "filename" )[i] = files[i];
//get list of columns
cols = dt1 << Get Column Names();
//for each column
for ( c=1, c <= N Items(cols), c++,
//add mean column to summary table if it isn't already there
if ( Contains( dts << Get Column Names(); , Parse( Char( cols[c] ) || "_mean" ) ) < 1,
dts << New Column( Char( cols[c] ) || "_mean" );
);
//find the mean and write it to summary table
Column( dts, Char( cols[c] ) || "_mean" )[i] = ColMean( Column( dt1, cols[c] ) );
//add max column to summary table if it isn't already there
if ( Contains( dts << Get Column Names(); , Parse( Char( cols[c] ) || "_max" ) ) < 1,
dts << New Column( Char( cols[c] ) || "_max" );
);
//find the max and write it to summary table
Column( dts, Char( cols[c] ) || "_max" )[i] = ColMax( Column( dt1, cols[c] ) );
); //end loop each column
//close file
close(dt1, no save);
); //end check for csv
); //end loop for each file제목 : Re : 여러 CSV 파일 요약요약 된 방법은?
제목 : Re : 여러 CSV 파일 요약다음은 CSV 파일에서 데이터가 어떻게 보이는지입니다. 파일 이름은 환자 식별자이기도합니다. 열 머리말로 요약하고 열에 파일 식별자가있는 요약 된 데이터 테이블을 만들려면 어떻게해야합니까? 스크린 샷 하단에서 파일 이름이 어떻게 보이는지 확인할 수 있습니다.
모든 CSV를 JMP 파일로 변환 할 수 있습니까? 도움이 될지 확실하지 않습니다.
누구든지 데이터 테이블 도구 추가 기능이이 경우에 작동하는지 알고 있습니까?
제목 : Re : 여러 CSV 파일 요약두 개의 가짜 테이블의 스크린 샷을 제공하고 최종 결과를 어떻게 보이게 할 수 있습니까? 네가 무엇을 요구하는지 알 수 없다.
제목 : Re : 여러 CSV 파일 요약지연 돼서 죄송합니다. 서비스 중이었고 환자를 돌봐야했습니다. 이제 막 돌아와.
아니 그들은 항상 같은 열 (A, B, C 등)을 가지고 있지는 않지만 그들은 같은 이름을 가지고 있습니다.
브라이언
제목 : Re : 여러 CSV 파일 요약(이 대답을 무시하고 빈스는 훨씬 더 나은 접근법을가집니다.)
파일 별 통계가 필요한 경우 Vince의 대답에 대한 변형입니다. 난 칼럼들이 일관성이 있다고 상상해.
path = "$desktop/csvFiles/";
files = Files In Directory( path );
answers = New Table( "Summary",
New Column( "N Rows", Numeric, "Continuous", Format( "Fixed Dec", 12, 0 ), Set Values( [] ) ),
New Column( "Mean(x)", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "Mean(y)", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "Mean(z)", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "sourceFile", character )
);
For( iFile = 1, iFile <= N Items( files ), iFile += 1,
file = path || files[iFile];
dt = Open( file, "text" );
dt2 = dt << Summary( Mean( :x ), Mean( :y ), Mean( :z ), Freq( "None" ), Weight( "None" ) );
answers << addrows( 1 );
answers:sourceFile = file || " " || Format( Creation Date( file ), "m/d/y h:m:s" );
answers:N Rows = dt2:N Rows[1];
answers:name( "Mean(x)" ) = dt2:name( "Mean(x)" )[1];
answers:name( "Mean(y)" ) = dt2:name( "Mean(y)" )[1];
answers:name( "Mean(z)" ) = dt2:name( "Mean(z)" )[1];
Close( dt, nosave ); // linked table closes too
);
내 파일은 이렇게 보였다.
x, y, z
1,2,3
4,5,6
요약 스크립트를 직접 작성한 파일의 테이블 스크립트를 사용했습니다. 변수를 복사하는 더 좋은 방법이있을 수 있습니다. JMP 13에서는 아이디어를 사용할 수 있습니다. 이리 하나의 명령문에서 전체 행을 지정합니다.
제목 : Re : 여러 CSV 파일 요약그래서 저는 이것에 대해 몇 가지 가정을하고 있습니다. 나는 벗어날 수있다.
모든 csv 파일에는 동일한 열이 있습니다.
각 파일에 대한 각 열의 집계 요약 (예 : 평균)을 작성하려고합니다.
Names Default to here(1);
dir = pick directory();
files = files in directory(dir);
dt = New Table("concat", New Column("File", character));
for(i=1, i<=nitems(files), i++,
if(endswith(files[i], "csv"), //just a check to make sure it's a csv
//break();
dt1 = open(dir||files[i], private);
dt1 << New Column("File", character, set each value(files[i]));
dt<<CONCATENATE></CONCATENATE>