示例#1
0
/**
 * Export code files.
 */
function opfe_list_to_array_process_codes()
{
    $records = opfe_list_to_array_read_file();
    opfe_list_to_array_validate_file($records[0]);
    $headers = array_shift($records);
    $full_file = '<?php

  /**
   * @file
   * Array of federal agency codes produced by Federal Inventory Program.
   * @see http://project-open-data.github.io/schema/#programCode
   */

  $federal_inventory_full_list = ';
    $small_file = '<?php

  /**
   * @file
   * Key/Vallue array of federal agencies produced by Federal Inventory Program.
   * @see http://project-open-data.github.io/schema/#programCode
   */

  $federal_inventory_small_list = ';
    $full_list = array();
    $small_list = array();
    foreach ($records as $key => $record) {
        foreach ($headers as $header_key => $header) {
            // Bureau code is the key.
            $full_result[$record[5]][$header] = $record[$header_key];
            $small_result[$record[5]] = $record[5] . ' - ' . $record[0] . ' - ' . $record[1];
        }
    }
    file_put_contents('federal_inventory_codes.php', $full_file . var_export($full_result, TRUE) . ';');
    file_put_contents('federal_inventory_list.php', $small_file . var_export($small_result, TRUE) . ';');
}
示例#2
0
/**
 * Export bureau files.
 */
function opfe_list_to_array_process_bureaus()
{
    $records = opfe_list_to_array_read_file(OPFE_CSV_BUREAU_CODES_FILE_NAME);
    $headers = array_shift($records);
    $file = '<?php
/**
 * @file
 * Declares Bureau codes.
 */

$bureau_codes = ';
    $list = array();
    foreach ($records as $key => $record) {
        foreach ($headers as $header_key => $header) {
            // Bureau code is the key.
            if ($record[3]) {
                $result["{$record['3']}:{$record['4']}"] = "{$record['3']}:{$record['4']} - {$record['2']}";
            }
        }
    }
    file_put_contents('omb-agency-bureau-treasury-codes.php', $file . var_export($result, TRUE) . ';');
}