Published
Edited
Dec 31, 2019
8 stars
Insert cell
Insert cell
jszip = require("jszip@3/dist/jszip.min.js")
Insert cell
archive = jszip.loadAsync(await FileAttachment("ssamatab1@2.zip").blob())
Insert cell
lines = (await archive.file("ssamatab1.txt").async("string")).split(/[\r\n]+/)
Insert cell
Insert cell
Insert cell
Insert cell
function parseLine(line) {
return {
"LAUS Code": line.substring(0, 15),
"State FIPS Code": line.substring(20, 22),
"Area FIPS Code": line.substring(29, 34),
"Area": line.substring(40, 99).trim(),
"Year": line.substring(99, 103),
"Month": line.substring(107, 109),
"Civilian Labor Force": +line.substring(110, 123).trim().replace(/,/g, ""),
"Employment": +line.substring(124, 141).trim().replace(/,/g, ""),
"Unemployment": +line.substring(141, 155).trim().replace(/,/g, ""),
"Unemployment Rate": +line.substring(155).trim()
};
}
Insert cell
Insert cell
parseLine(lines[Math.floor(Math.random() * lines.length)])
Insert cell
Insert cell
data = lines.slice(3, -3).map(parseLine)
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