[{"created":"20250508091535136","text":"\\procedure convert-csv()\n<!-- create the setting row -->\nCSV delimiter:&nbsp;\n<$tiddler tiddler=\"$:/temp/convertxls\">\n<$radio field=delimiter value=\"tab\" default=\"tab\"> tab</$radio>\n<$radio field=delimiter value=\"comma\" default=\"tab\"> comma</$radio>\n</$tiddler>&nbsp;|&nbsp;\n<$checkbox tiddler=\"$:/temp/convertxls\" field=\"header\" checked=\"yes\" unchecked=\"no\" default=\"no\">&nbsp;Has header?</$checkbox><br/>\n\n<!--Create the input textbox -->\n<$edit-text tiddler=\"$:/temp/convertxls\" tag=textarea class=\"tc-max-width\"/>\n<!-- Preview output checkbox-->\n<$checkbox tiddler=\"$:/temp/convertxls\" field=\"preview\" checked=\"open\" unchecked=\"closed\" default=\"closed\"> Prview?</$checkbox>\n\n<!--Define required variables-->\n<$let\n  newline={{{ [charcode[10]] }}}\n\tth=     {{{ [<newline>addprefix[h]] }}}\n  tab=    {{{ [charcode[9]] }}}\n\tcomma = `,(?=(?:[^'\"]|'[^']*'|\"[^\"]*\")*$)`\n\tdelim=  {{{ [[$:/temp/convertxls]get[delimiter]match[comma]then<comma>else<tab>]  }}}\n\theader= {{{ [[$:/temp/convertxls]get[header]match[yes]else[no]] }}}\n  input=  {{$:/temp/convertxls}}\n  output= {{{ [<input>split<newline>!is[blank]search-replace:g:regexp<delim>,[|]] :map[split[|]trim[]trim[\"]trim[']join[|]] :and[addprefix[|]addsuffix[|]join<newline>] }}}\n\toutput= {{{ [<header>match[yes]]:then[<output>search-replace<newline>,<th>]:else[<output>] }}}}  >\n\t<$macrocall $name=\"copy-to-clipboard-above-right\" src=<<output>> />\n\t<!-- Preview output-->\n\t<%if [[$:/temp/convertxls]get[preview]match[open]] %>\n\t<div style=\"overflow-x:auto; max-width:100%\">\n\t\t<$transclude $variable=\"output\" $mode=\"block\"/>\n\t</div>\t\n\t<%endif%>\n</$let>\n\\end\n\n<<convert-csv>>","tags":"","title":"Table from CSV","modified":"20250513051704803"}]