Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
simplify BLS data parser; new data with % per #955
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Allen committed Dec 12, 2015
1 parent 76891e9 commit 674197f
Show file tree
Hide file tree
Showing 3 changed files with 12,073 additions and 12,098 deletions.
8 changes: 7 additions & 1 deletion data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ jobs: $(JOBS_FILES)
all_production: $(ALL_LANDS_PRODUCTION_FILES)

jobs/wage-salary.tsv:
bin/parse-bls.js _input/bls/*.csv > $@
bin/parse-bls.js _input/bls/????/joined.tsv \
| bin/abbr-state.js \
--if tsv \
--of tsv \
--states $(input)geo/states.csv \
--field State \
> $@

# national revenues by commodity and revenue type
national/revenues.tsv: state/revenues.tsv offshore/revenues.tsv
Expand Down
21 changes: 3 additions & 18 deletions data/bin/parse-bls.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,12 @@ var mapRow = function(d) {
var loadFiles = function(done) {
async.mapSeries(inputFiles, function(filename, next) {
console.warn('reading:', filename);
var rows = [];
fs.createReadStream(filename)
.pipe(tito.createReadStream('csv'))
.pipe(thru(function(d, enc, next) {
if (isValidRow(d)) {
// console.warn('add:', d[areaAggrCode]);
rows.push(mapRow(d));
} else {
// console.warn('skip:', d[areaAggrCode]);
}
next();
}))
.on('finish', function() {
next(null, rows);
});
var type = filename.split('.').pop();
util.readData(filename, tito.createReadStream(type), next);
}, function(error, years) {
console.warn('loaded %d years', years.length);
var rows = years.reduce(function(collection, set) {
return collection.concat(set.filter(function(d) {
return d.Jobs > 0;
}));
return collection.concat(set);
}, []);
console.warn('got %d rows', rows.length);
done(null, rows);
Expand Down
Loading

0 comments on commit 674197f

Please sign in to comment.