-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from aspittel/feature/data-script
add script for updating the data from airtable
- Loading branch information
Showing
6 changed files
with
5,942 additions
and
2,784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}) | ||
} | ||
}) |
Oops, something went wrong.