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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more