Public
Edited
Mar 9, 2024
Insert cell
Insert cell
viewof input = Inputs.textarea()
Insert cell
html`<textarea style="width: 100%; height: 10em">${JSON.stringify(
rows,
null,
2
)}</textarea>`
Insert cell
rows = {
var container = document.createElement("div");
container.innerHTML = input;
var cols = Array.from(container.querySelectorAll("th")).map((th) =>
th.innerText.trim()
);
var rows = Array.from(container.querySelectorAll("tr"))
.slice(1)
.map((tr) => {
var values = Array.from(tr.querySelectorAll("td")).map((td) =>
td.innerText.trim()
);
return cols.reduce((obj, col, index) => {
obj[col] = values[index];
return obj;
}, {});
});
return cols, rows;
}
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