Improved Draw_Table

john's Avatar

john

03 Mar, 2024 04:34 AM

Attached is an improved version of my draw_table node.

Draw_table converts a data table to a graphical object that you can include in your output. It produces a table that looks somewhat like the data view, but with cleaner column spacing.

Like Nodebox's data view, all columns are left-justified. This can make columns of floating point numbers harder to read. Hence, my new option: "Align numbers".

If you check this option, draw_table will detect which table columns are numeric and align the numbers in those columns to their decimal points. It will automatically handle numbers with dollar and percent signs (placing minus signs in front of dollar signs when needed). For larger numbers it will insert separators (comma or period) every three digits depending on local region.

The attached demo and screenshot show one example. Try clicking the "Align numbers" option on and off to see the difference. The date column is recognized as non-numeric (even though all entries contain nothing but numbers and dashes). The other three columns are recognized as numeric and correctly aligned despite the dollar and percent signs.

Detecting and aligning numeric columns is tricky. I tried to anticipate many possible variations, but some unusual tables may fool my node. So if anyone out there uses this node and finds a case where this new option fails, I would really appreciate you sending me the example.

Enjoy!

John

Note: the demo requires dateformat.clj to quickly generate fake dates, but no external libraries are required by the draw_table node.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • draw_table_screenshot.png 890 KB
  • draw_table_demo.zip 15.1 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

10 Sep, 2024 03:41 AM
09 Sep, 2024 02:15 PM
07 Sep, 2024 05:16 AM
05 Sep, 2024 02:21 AM
04 Sep, 2024 05:01 AM

 

03 Sep, 2024 10:07 AM
02 Sep, 2024 05:56 AM
31 Aug, 2024 11:07 PM
27 Aug, 2024 12:08 AM
26 Aug, 2024 01:02 PM
26 Aug, 2024 07:18 AM