Published
Edited
Jun 22, 2021
2 forks
Importers
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mdTableRendered = md`${mdTable}`
Insert cell
Insert cell
Insert cell
md`${mdTable}`
Insert cell
md`## Usage in Observable

~~~js
import {dataToMarkdown} from "@john-guerra/csv-to-markdown-table""
~~~
and then
~~~js
mdTable = dataToMarkdown(yourData)
~~~
`
Insert cell
async function dataToMarkdown(data) {
if (!Array.isArray(data) || data.length<0) throw "Please provide an array with elements";
let markup;
const columns = Object.keys(data[0]);

markup = `| ${columns.join(" | ")} | `;
markup = markup.concat(`\n| ${columns.map(_ => "---").join("|")} | `);
data.forEach(d =>
markup = markup.concat(`\n| ${columns.map(c => d[c]).join("|")} | `)
);

return markup;
}
Insert cell
d3 = require("d3-dsv")
Insert cell
import {dataInput} from "@john-guerra/file-input-with-default-value"

Insert cell
data
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more