Split Excel file into several Excel Files or several Mat Files based on values of a column

조회 수: 6 (최근 30일)
Hello everyone,
I have an excel file with several columns:
Does anyone know how to split this file into some EXCEL files or MAT files based on the similar value of the first column? in this case, there are 3 values (1, 2, 3) so this file will be splitted into 3 excel files. Let's say the first file name will be Sta_1, the second file name will be Sta_2 and so on.
best regards

채택된 답변

VINAYAK LUHA
VINAYAK LUHA 2023년 9월 9일
편집: VINAYAK LUHA 2023년 9월 9일
Hi Adi,
As per my understanding you wish to organize your data into separate excel files based on the data values in Station column.
Here's how this can be done -
data = readtable(pathToExcelFile)
stations = unique(data.Station)
for i=1:numel(stations)
x = data(data.Station==stations(i), :);
writetable(x,"Sta_"+num2str(stations(i))+".xlsx");
end
Hope this helps
  댓글 수: 3
Adi Purwandana
Adi Purwandana 2023년 9월 9일
Thank you very much @VINAYAK LUHA! it solved my case. Thanks also to @Image Analyst and @Dyuman Joshi for the advice. I'll learn it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by