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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more