Public
Edited
Apr 24, 2023
Insert cell
Insert cell
create = `
CREATE TABLE vouchers(
code VARCHAR(11) NOT NULL,
A_or_B VARCHAR(1) NOT NULL,
profiel VARCHAR(27) NOT NULL,
gebruikt BOOL NOT NULL
);
`
Insert cell
viewof file = html`<input type="file">`
Insert cell
rows = ssv.parse(await file.text())
Insert cell
console.log(query)
Insert cell
function error(message) {
throw new Error(message);
}
Insert cell
better_rows = rows.map((row) => {
let profiel = row["Organisatie profiel(en)"];
return {
code: row.Code,
A_or_B: row["Test groep"],
profiel:
profiel === "Werkgever: onder €40.000"
? "werkgever-onder-40.000"
: profiel === "Werkgever: boven €40.000"
? "werkgever-boven-40.000"
: profiel === "Kennisinstelling: MBO"
? "kennisinstelling-mbo"
: profiel === "Kennisinstelling: HBO of WO"
? "kennisinstelling-hbo-of-wo"
: error(`HUH: ${profiel}`),
gebruikt: row["Gebruikt"]
};
})
Insert cell
query = better_rows
.map((x) => {
return `INSERT INTO vouchers(code, A_or_B, profiel, gebruikt) VALUES ('${x.code}', '${x.A_or_B}', '${x.profiel}', ${x.gebruikt});`;
})
.join("\n")
Insert cell
_.uniq(rows.map((x) => x["Organisatie profiel(en)"]))
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