필터 지우기
필터 지우기

Do anyone know how to merge several (80-90) csv file data into 1 file?

조회 수: 2 (최근 30일)
I have to merge data from several csv files into one csv file and find the maximum value of each column.
How shall I do it?

채택된 답변

Argon
Argon 2012년 11월 1일
편집: Argon 2012년 11월 1일
Assuming that all files have the same columns I'd do something like this:
  • where ncols is number of columns
  • preallocate max value variable: m = zeros(1, ncols);
  • loop over all files
  • read csv data using csvread into variable data
  • m = max(max(data), m);
  • end loop
m of course is your result.
  댓글 수: 5
Argon
Argon 2012년 11월 1일
There is not "one" function that does that as far as I know -- you will probably have to iterate over all your files and use csvread and write them to disk again, something like this:
files = {'file1.csv', 'file2.csv'};
cellfun(@(x) dlmwrite('output.csv', csvread(x), '-append'), files);
Though you might have to tweak that a bit, it hasn't been tested.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by