Published
Edited
Apr 16, 2020
2 stars
Insert cell
md`# Lido XML as Tree`
Insert cell
Insert cell
xmlstring
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hier = d3.hierarchy(data)
Insert cell
values = hier.leaves().map(l => ({ ...l.data, path: hier.path(l).map(h => h.data.name).join(".")}))
Insert cell
values.map(d => d.value)
Insert cell
Insert cell
viewof files = html`<input name="files" type=file accept="text/xml" multiple>`
Insert cell
lidoFields = {
let out = []
for(let file of Array.from(files)) {
let text = await file.text();
let lido = parser.parse(text, {ignoreNameSpace: true }).lidoWrap.lido
let data = lido2tree(lido, "lido")
let hier = d3.hierarchy(data)
let values = hier.leaves().map(l => ({ ...l.data, path: hier.path(l).map(h => h.data.name).join(".")}))
let elem = { file: file.name }
for(let value of values){
elem[value.path] = value.value
}
out.push(elem)
}
return out
}
Insert cell
DOM.download(serializeCsv(lidoFields), "mek-fields.csv", "Download CSV")
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
json2csv = require("json2csv")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {fileInput} from "@mbostock/file-input"
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
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