congress = (int) $doc['session']; $amdt->chamber = (string) $doc['chamber']; $amdt->number = (int) $doc['number']; //// look up the bill being amended $type = (string) $doc->amends['type']; $number = (int) $doc->amends['number']; $bill = Bill::get_by_congress_type_number($amdt->congress, $type, $number); $amdt->bill_id = $bill->id; $amdt->sequence = (int) $doc->amends['sequence']; $amdt->offered = (int) $doc->offered['date']; $amdt->sponsor_rep_id = (int) $doc->sponsor['id']; $amdt->description = (string) $doc->description; $amdt->save(); echo "{$amdt->congress} {$amdt->chamber} {$amdt->number} done.\n"; } if (isset($_SERVER['argv'])) { if ($_SERVER['argv'][0] != 'amendment.php') { return; } if (count($_SERVER['argv']) > 1) { //// parse arguments parseAmendment($_SERVER['argv'][1]); } else { //// process all current congress amendments in the data dir $current = get_current_congress_session(); $amdts_dir = $data_dir ."/us/{$current['congress']}/bills.amdt"; $listing = scandir($amdts_dir); foreach ($listing as $filename) { $path ="{$amdts_dir}/{$filename}"; if (is_file($path) && (substr($filename, strlen($filename) - 4) == '.xml')) { parseAmendment($path); } } } } ?>