How to split data from being in one excel file cell into multiple column

조회 수: 8 (최근 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

답변 (3개)

Sulaymon Eshkabilov
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?
  댓글 수: 1
Ahmed Abdulhameed M Almahdi
Ahmed Abdulhameed M Almahdi 2019년 5월 26일
편집: Ahmed Abdulhameed M Almahdi 2019년 5월 26일
Here is the excel file attached. My goal here is to set the data in this format using matlab
Screen Shot 2019-05-25 at 9.02.21 PM.png
The end goal here is to write script where I just need to write the excel file name and once I run the code it would sort the data into this attached format
thank you
Ahmed

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


Ahmed Abdulhameed M Almahdi
Ahmed Abdulhameed M Almahdi 2019년 5월 26일
Of course, here is the excel file of the data
thank you
Ahmed

Pullak Barik
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

카테고리

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