Weather.gov Reporting Station List Importer is a script to parse the XML file provided by weather.gov and insert the records into a MySQL database.
- PHP 5.3 +
- MySQL 5.x
- This script is designed to run on the command line.
Create the database (insert your database name):
CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
Create the table:
CREATE TABLE IF NOT EXISTS t_station (
c_id SERIAL PRIMARY KEY,
c_code VARCHAR(8) DEFAULT NULL,
c_state VARCHAR(2) DEFAULT NULL,
c_name VARCHAR(64) DEFAULT NULL,
c_lat DEC(7,4) SIGNED DEFAULT NULL,
c_lng DEC(7,4) SIGNED DEFAULT NULL,
c_uxml VARCHAR(128) DEFAULT NULL,
c_urss VARCHAR(128) DEFAULT NULL,
c_uhtml VARCHAR(128) DEFAULT NULL
Download weather.gov-stationlist-import.php and edit it, setting your database configuration:
$CFG['db']['host'] = 'localhost';
$CFG['db']['port'] = 3306;
$CFG['db']['user'] = null;
$CFG['db']['pass'] = null;
$CFG['db']['name'] = null;
Run the script -- it should only require a few seconds.
This project is BSD (2 clause) licensed.