Published
Edited
Mar 30, 2020
Insert cell
md`# Sim Output Parsing`
Insert cell
d3 = require('d3')
Insert cell
f = FileAttachment("CI_HQ_SD_3_91_R0=2.4.avNE.severity.adunit.tsv")
Insert cell
rows = d3.tsvParse(await f.text())
Insert cell
function parseHeader(h) {
const [datum, region] = h.split('_');
return [datum, region.replace(/adu/, '')];
}
Insert cell
function parseData(data) {
const regions = {}
data.forEach(r => {
Object.keys(r).forEach(k => {
if (k === 't') return; // timestamp, skip
const [datum, region] = parseHeader(k);
if (!(region in regions)) {
regions[region] = {};
}
if (!(datum in regions[region])) {
regions[region][datum] = [];
}
regions[region][datum].push(+r[k]);
});
})
return regions
}
Insert cell
parseData(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