inputString = fileread(csvFileName); % using multiple regular expressions to clear up special chars htmlFriendly = regexprep(regexprep(regexprep(regexprep(inputString,... '&','&'),... '"','"'),... '<','<'),... '>','>'); % split string into cell array tableValues = regexp(regexp(htmlFriendly,'(\r\n|\r|\n)','split')',',','split'); %%% print in html format %%% % first line gets treated as header fprintf(1,['\n\t' sprintf('\n\t\t',tableValues{1,:}{:})]) % print remaining lines of csv as html table (rows 2:end in cell array of csv values) cellfun(@(x)fprintf(1,['\n\t' sprintf('\n\t\t',x{:}) '\n\t']),tableValues(2:end)) fprintf(1,'\n
%s
%s
')