Exemple #1
0
/**
 * @param $in_address
 * @param $in_city
 * @param $in_state
 * @return string
 */
function normalize_address($in_address, $in_city, $in_state)
{
    $address_converter = new Convissor\address\AddressStandardizationSolution();
    $single_line_address = $address_converter->AddressLineStandardization($in_address);
    $single_line_address .= ', ' . strtoupper($in_city) . ', ' . strtoupper($in_state);
    // We keep unit 'internal'
    return $single_line_address;
}
Exemple #2
0
require '../../config/config.php';
require '../../vendor/Convissor/address/AddressStandardizationSolution.php';
$census = new \Code4KC\Address\Census();
$row = 0;
$out = array();
$names = array();
global $dbh;
$totals = array('input' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address_alias' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address_keys' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'city_address_attributes' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0));
if (($handle = fopen("kcmo_addresses_kiva_nbrhd_06_18_2015.csv", "r")) !== FALSE) {
    try {
        $dbh = new PDO("pgsql:dbname={$DB_NAME}", $DB_USER, $DB_PASS);
    } catch (PDOException $e) {
        error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
        throw new Exception('Unable to connect to database');
    }
    $address_converter = new Convissor\address\AddressStandardizationSolution();
    $address = new \Code4KC\Address\Address($dbh, true);
    $address_alias = new \Code4KC\Address\AddressAlias($dbh, true);
    $address_keys = new \Code4KC\Address\AddressKeys($dbh, true);
    $city_address_attributes = new \Code4KC\Address\CityAddressAttributes($dbh, true);
    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
        $num = count($data);
        $row++;
        print "{$row}\n";
        if ($row == 1) {
            for ($c = 0; $c < $num; $c++) {
                $names[$c] = $data[$c];
            }
        } else {
            $rec = array();
            for ($c = 0; $c < $num; $c++) {