How to split data from being in one excel file cell into multiple column
4 次查看(过去 30 天)
显示 更早的评论
Hello,
I am dealing with large number of excel file data on this format where for example ( Class A1 B1 C1) are all in one cell (one raw & one column) and the data spaced out using the "Tab" button and I need to split them from being in one raw and one column to be in one raw and four column instead using Matlab. Please see the screenshot attached for better illustration of the situation.
Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/220999/image.png)
0 个评论
回答(3 个)
Sulaymon Eshkabilov
2019-5-26
Ahmed,
Could you please post your sample data in Excel file to test and provide a solution to your problem?
Pullak Barik
2019-6-10
I guess the following code shall work for you-
clc;
clear;
c = readcell('test1.xlsx');
x = c(cellfun(@ischar, c));
split1=regexp(x, '\t', 'split');
result = vertcat(split1{:,:});
The required data is stored as a cell matrix named 'result'. It can be exported to an excel file using writecell command, find a reference to it in the following link- Write cell array to file
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!