CBER Data Grabber
A set of classes used by the Ball State University Center for Business and Economic Research County Profiles website for pulling data from US federal data APIs., (*1)
composer require ballstatecber/cber-data-grabber:dev-master
Make sure you first have a US Census Bureau API Key., (*2)
Getting processed data and saving it to a CSV file:, (*3)
ACSUpdater::setAPIKey('api key goes here');
$year = '2013';
$stateId = '18'; // Indiana
$category = ACSUpdater::$POPULATION_AGE;
$processedData = ACSUpdater::getCountyData($year, $stateId, $category);
$fileName = date('Y-m-d').'_processed_county_'.$categoryName.'_'.$stateId.'_'.$year.'-00-00.csv';
ACSUpdater::writeProcessedCSV($processedData, $fileName);
Getting raw data and saving it to a CSV file:, (*4)
ACSUpdater::setAPIKey('api key goes here');
$year = '2013';
$stateId = '18'; // Indiana
$category = ACSUpdater::$POPULATION_AGE;
$rawData = ACSUpdater::getRawCountyData($year, $stateId, $category);
$fileName = date('Y-m-d').'_raw_county_'.$categoryName.'_data_'.$stateId.'_'.$year.'-00-00.csv';
ACSUpdater::writeRawCSV($rawData, $fileName, $map);
CSV files are saved in the same directory that executes this script., (*5)
Available data categories:, (*6)
ACSUpdater::$POPULATION_AGE
ACSUpdater::$HOUSEHOLD_INCOME
ACSUpdater::$ETHNIC_MAKEUP
ACSUpdater::$EDUCATIONAL_ATTAINMENT
ACSUpdater::$INEQUALITY_INDEX
BEA Updater (Bureau of Economic Analysis)
Example for saving data to a CSV file:, (*7)
BEAUpdater::setAPIKey('api key goes here');
$year = '2014';
$stateId = '18'; // Indiana
BEAUpdater::updateAllCountyData($year, $stateId);
BEAUpdater::updateCountyData($year, $stateID, BEAUpdater::$WAGES, true);
BLS Updater (Bureau of Labor Statistics)
Example for saving data to a CSV file:, (*8)
$endYear = '2013';
$stateID = '18'; // Indiana
BLSUpdater::updateAllCountyData($stateID, $endYear);