Is there a tool to create a table by inserting values either as a block copied from excel or colums by column

The TW-table syntax is sleek - but for me it is a drag getting an OCR’ed tables into a tiddler - because usually they are recognized as collumns. Is there a trick to do that?

If the source is a PDF, I would recommend using tabula rather than OCR: https://tabula.technology/

1 Like

This may not be what you’re looking for, but I also often copy-paste from Excel into the body of a tiddler a lot. I just wrote a simple procedure to parse the paste values - in Windows it separates lines by newline and columns by tab. I save this off as a global procedure and then use like the below.

\procedure data(text)
<!-- This is so you can copy/paste in a range from Excel and make an HTML table-->
<table>
<$let newline={{{ [charcode[10]] }}} tab={{{ [charcode[9]] }}}>
<$list filter="[<text>split<newline>!match[]first[]]" variable="row" counter="rownum">
<$list filter="[<row>split<tab>]" variable="col" counter="colnum">
<th>
<<col>>
</th>
</$list>
</$list>
<$list filter="[<text>split<newline>!match[]butfirst[]]" variable="row">
<tr>
<$list filter="[<row>split<tab>]" variable="col">
<td><<col>></td>
</$list>
</tr>
</$list>
</$let>
</table>
\end

<<data "
Name	Age
Adam	33
Bob	22
Charlie	44
">>
4 Likes

for spreadsheet type data rendered to a table, you can just put the csv data directly into TW, and set the Type as text/csv (i’m not sure why that’s not in the dropdown menu as a recognised type - I found it reading TW doco)

I’m not sure if excel can copy a block of data as CSV, nor what comma escaping/quoting handling TW uses, but for basic CSV data in a nice readable format, this is pretty neat

You can also render CSV data within a normal tidbit via the $$$ handler:

Editing table data by adding columns after the table has already started… that is not something I’ve heard of being able to be handled in TW

4 Likes

An older yet still practical solution is Tobias Beer’s conversion table.

tb5 — convertable

1 Like

To include literal commas within a CSV value, enclose the entire value in quotes:

a,"b,c",d

To include literal quotes within a CSV value, enclose the entire value in quotes AND use doubled quotes for the literal quote character:

a,"this ""is"" b",c

-e

2 Likes

Thank you, @stobot. This is an excellent piece of work. I have added a textbox and a button to copy the output. When integrated into the Sidebar, it functions as convenient tool for pasting data pasted from Excel or CSV files and effortlessly creating a table.

Thanks for your replies… using my values I still have the problem, that the OCR result gives me columns after column after column.
But with a detour over Excel @stobot’s solution works great.

I adopted @stobot’s trick, it works great, the only flaw is that the TW-syntax for merging cells does not work yet.