Published
Edited
May 27, 2021
12 stars
Insert cell
Insert cell
function compress(rows) {
const headers = Object.keys(rows[0]);

return {
headers,
rows: rows.map((row) => {
return headers.map((header) => row[header]);
}),
};
}

Insert cell
function decompress(data) {
return data.rows.map((row) => {
let obj = {};
for (let i = 0; i < data.headers.length; i++) {
obj[data.headers[i]] = row[i];
}
return obj;
});
}
Insert cell
raw = FileAttachment("username@1.csv").csv()
Insert cell
encoded = compress(raw)
Insert cell
decoded = decompress(encoded)
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