Skip to content

Instantly share code, notes, and snippets.

@rianoc
Last active September 26, 2023 06:02
Show Gist options
  • Save rianoc/d692c2a242ffa0479284b16410d25e6f to your computer and use it in GitHub Desktop.
Save rianoc/d692c2a242ffa0479284b16410d25e6f to your computer and use it in GitHub Desktop.
Kdb+ to Markdown
q)t:([] a:1 2 3;s:`lll`h`j;longNameColumn:("ww";"ko";"ooo"))
q)t
a s   longNameColumn
--------------------
1 lll "ww"
2 h   "ko"
3 j   "ooo"
markdown:{
 r:{.Q.ty[x] in "hijef"} each value flip x;
 -1 {"|","" sv x} each flip {w:2+max count each x;x:" ",/:x;{[w;r;x] $[$[r;neg w;w];x],"|"}[w;y] each (x[0];$[y;#[w-1;"-"],":";w#"-"]),1_x}'[flip vs["\t"] each .h.td (first system"c") sublist x;r];
 }
q)markdown q
q)markdown t
|  a| s   | longNameColumn |
|--:|-----|----------------|
|  1| lll | ww             |
|  2| h   | ko             |
|  3| j   | ooo            |
a s longNameColumn
1 lll ww
2 h ko
3 j ooo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment