FS = "," -- field separator csv = [[ Character,Speech The multitude,The messiah! Show us the messiah! Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! The multitude,Who are you? Brians mother,I'm his mother; that's who! The multitude,Behold his mother! Behold his mother! ]] csv = csv:gsub( "<", "<" ) csv = csv:gsub( ">", "&gr;" ) html = { "" } for line in string.gmatch( csv, "(.-\n)" ) do str = "" for field in string.gmatch( line, "(.-)["..FS.."?\n?]" ) do str = str .. "" end str = str .. "" html[#html+1] = str; end html[#html+1] = "
" .. field .. "
" for _, line in pairs(html) do print(line) end