Skip to content

Commit

Permalink
Merge pull request #57 from aspittel/feature/data-script
Browse files Browse the repository at this point in the history
add script for updating the data from airtable
  • Loading branch information
aspittel committed Oct 24, 2018
2 parents 3710cdf + 6028bb9 commit 74b42e6
Show file tree
Hide file tree
Showing 6 changed files with 5,942 additions and 2,784 deletions.
27 changes: 27 additions & 0 deletions data-formatting/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require('dotenv').config()
const fs = require('fs')

const base = require('airtable').base('appyahDjTyD3MR0tU')
let data = []

base('Data').select({
view: 'published'
}).eachPage(function page (records, fetchNextPage) {
records.forEach(record => {
delete record.fields['Which underrepresented group are you a member of?']
delete record['_table']
delete record['_rawJson']
})
data = data.concat(records)
fetchNextPage()
}, (err) => {
if (err) {
console.error(err)
} else {
fs.writeFile('src/data.json', JSON.stringify(data), function (err, _) {
if (err) console.log(err)
console.log('Successfully Written to File.')
console.log(data.length + ' records')
})
}
})
Loading

0 comments on commit 74b42e6

Please sign in to comment.