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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!