Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert Wolfram Language data into Markdown-friendly table strings
| ResourceFunction["MarkdownTableString"][data] creates a Markdown table string of data. | |
| ResourceFunction["MarkdownTableString"][data,{header1,header2,…}] creates a Markdown table string with column headers headeri. | |
| ResourceFunction["MarkdownTableString"][assoc,k,v] creates a Markdown table string for the values in assoc with headers k and v. | 
Create a Markdown string for a simple table:
| In[1]:= | ![ResourceFunction["MarkdownTableString"][
 {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/2d492501ad4c779b.png) | 
| Out[1]= |  | 
Create a Markdown string for a table with column headers:
| In[2]:= | ![ResourceFunction["MarkdownTableString"][
 {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}},
 {"A", "B", "C"}
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/7fd888b0b915bb20.png) | 
| Out[2]= |  | 
Create a Markdown string for a Dataset:
| In[3]:= | ![ResourceFunction["MarkdownTableString"][
 Dataset[
  {
   <|"a" -> 1, "b" -> 2, "c" -> 3|>,
   <|"b" -> 4, "a" -> 5, "c" -> 6|>,
   <|"b" -> 7, "a" -> 8, "c" -> 9|>
   }
  ]
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/1ab4064b638ce5f6.png) | 
| Out[3]= |  | 
Simple Association formatted as labeled rows:
| In[4]:= | ![ResourceFunction[
 "MarkdownTableString"][<|"A" -> 1, "B" -> 2, "C" -> 3|>]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/10714509a7f8dc12.png) | 
| Out[4]= |  | 
Add a header to label just the keys:
| In[5]:= | ![ResourceFunction[
 "MarkdownTableString"][<|"A" -> 1, "B" -> 2, "C" -> 3|>, "Letter"]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/3bed76af86d4ffa6.png) | 
| Out[5]= |  | 
Add another header to label the values:
| In[6]:= | ![ResourceFunction[
 "MarkdownTableString"][<|"A" -> 1, "B" -> 2, "C" -> 3|>, "Letter", "Number"]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/5ccb5af078c759f9.png) | 
| Out[6]= |  | 
Label just the values:
| In[7]:= | ![ResourceFunction[
 "MarkdownTableString"][<|"A" -> 1, "B" -> 2, "C" -> 3|>, Automatic, "Number"]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/0ed24bb3e6e2f551.png) | 
| Out[7]= |  | 
Format a Dataset in Markdown with row and column headers:
| In[8]:= | ![ResourceFunction["MarkdownTableString"][
 Dataset[
  <|
   "Row1" -> <|"a" -> 1, "b" -> 2, "c" -> 3|>,
   "Row2" -> <|"b" -> 4, "a" -> 5, "c" -> 6|>
   |>
  ]
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/3e029e0194d4c372.png) | 
| Out[8]= |  | 
Specify a specific string to use for values that are not present in the data:
| In[9]:= | ![ResourceFunction["MarkdownTableString"][
 {{1, 2, 3}, {4, 5}, {7, 8, 9}},
 {"A", "B", "C"},
 "MissingTableElement" -> "MISSING"
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/5262edc87b8dc667.png) | 
| Out[9]= |  | 
Create a Markdown table of food data:
| In[10]:= | ![properties = {"Name", "FoodCount", "CommonOutsideColor", "CommonInsideColor", "ApproximateShape"};
data = EntityValue[EntityValue["FoodType", "SampleEntities"], properties];
markdown = ResourceFunction["MarkdownTableString"][
  data /. {e_Entity :> CommonName[e], _Missing -> "-"}, properties]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/505995d6f5de4a7f.png) | 
| Out[11]= |  | 
Copy the table to the clipboard:
| In[12]:= | ![CopyToClipboard[markdown]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/1601db4a8bf17eae.png) | 
Paste the table into a Markdown viewer (such as dillinger.io) to see the results formatted:

Missing values are automatically padded:
| In[13]:= | ![ResourceFunction["MarkdownTableString"][
 {{1, 2, 3}, {4, 5}, {7, 8, 9}},
 {"A", "B", "C"}
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/293bfc047349fdb3.png) | 
| Out[13]= |  | 
Partial headers are padded:
| In[14]:= | ![ResourceFunction["MarkdownTableString"][
 {
  <|"a" -> 1, "b" -> 2, "c" -> 3|>,
  <|"b" -> 4, "a" -> 5, "c" -> 6|>,
  <|"b" -> 7, "a" -> 8, "c" -> 9|>
  },
 {"A", "B"}
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/679987f0e52e7a02.png) | 
| Out[14]= |  | 
An Association with List values by default indicates labeled columns of data:
| In[15]:= | ![a = <|"A" -> {1, 2, 3}, "B" -> {4, 5, 6}, "C" -> {7, 8, 9}|>;
ResourceFunction["MarkdownTableString"][a]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/4667313fae545c76.png) | 
| Out[16]= |  | 
Separate the keys and values to make the data correspond to rows:
| In[17]:= | ![ResourceFunction["MarkdownTableString"][Values[a], Keys[a]]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/63b543a79bc85210.png) | 
| Out[17]= |  | 
The option "MissingTableElement" does not cover values of the form Missing[…]:
| In[18]:= | ![data = {{1, 2}, {3, 4}, {5, Missing[]}};
ResourceFunction["MarkdownTableString"][data, "MissingTableElement" -> "MISSING"]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/2cd672717c83a88c.png) | 
| Out[19]= |  | 
Use DeleteMissing to actually remove the data so that "MissingTableElement" will be used:
| In[20]:= | ![ResourceFunction["MarkdownTableString"][DeleteMissing /@ data, "MissingTableElement" -> "MISSING"]](https://www.wolframcloud.com/obj/resourcesystem/images/ddc/ddce660e-d4bb-496a-a537-6902e6b8c02a/2d320763aac756bf.png) | 
| Out[20]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License