Skip to content

Instantly share code, notes, and snippets.

@grandadmiral-thrawn
Created October 2, 2014 22:12
Show Gist options
  • Save grandadmiral-thrawn/b217d4fe3e87b46c00a7 to your computer and use it in GitHub Desktop.
Save grandadmiral-thrawn/b217d4fe3e87b46c00a7 to your computer and use it in GitHub Desktop.
cellparser
function [outputmat] = cellparser(cellarray)
% CELLPARSER/1(CELLARRAY) converts a cellarray of Nx1 into a cellarray of Nxnumber_of_comma_separated_fields
% given a cell array with comma delimiters that you don't know the input-- for example you just read in a .csv with new lines but didn't comma parse
% parse the cell array into however many columns it contains
for i = 1:length(cellarray)
parseline = regexp(cellarray{i},',','split');
bob = length(parseline);
outputmat(i,1:bob) = parseline;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment