How to shift the entire columns in raw file to the left and hence deleting all the empty columns in the sheet in matlab?

1 view (last 30 days)
I have imported a table from excel sheet into a uitable.There are empty columns in it.I want replace these empty columns with the next columns in the sheet.
As you can see in the table attached,there are empty columns.I want to delete these empty columns and shift the columns which are next to it to the left. My new table should contain no empty columns
[~,~,raw2] = xlsread(filename,'Markings');
[rows2 ,columns2] =size(raw2);
for k =2:rows2
for l=2:columns2
if ~isnan(raw{k,l})
tempRaw2(l-1,k-1) = matchStr2;
end
Kindly help me with this.

Answers (1)

dpb
dpb on 9 May 2018
t=readtable(filename,'Sheet','Markings'); % tables are much more simpler than raw cell arrays
ix=~all(ismissing(t)); % find columns with no data, complement is any
t=t(:,ix); % save only those...
Will have to clean up the existing sheet to write a clean one; if just writetable the new table beginning at A1 will leave the existing data past the last column as it was.

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!