I was wondering if anyone has had any success loading GTFS data to a mySQL database. I've looked all over the place for a good tutorial but I can't find anything that has been helpful.
I succeed in importing GTFS files into MySQL.
CREATE DATABASE gtfs
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
For instance, create the table stops for stops.txt,
-- stop_id,stop_code,stop_name,stop_lat,stop_lon,location_type,parent_station,wheelchair_boarding
CREATE TABLE `stops` (
stop_id VARCHAR(255) NOT NULL PRIMARY KEY,
stop_code VARCHAR(255),
stop_name VARCHAR(255),
stop_lat DECIMAL(8,6),
stop_lon DECIMAL(8,6),
location_type INT(2),
parent_station VARCHAR(255),
wheelchair_boarding INT(2),
stop_desc VARCHAR(255),
zone_id VARCHAR(255)
);
For instance, load the local file stops.txt into the table stops,
LOAD DATA LOCAL INFILE 'stops.txt' INTO TABLE stops FIELDS TERMINATED BY ',' IGNORE 1 LINES;
The complete source code with an example is placed on GitHub (here). Make some slight changes for your purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With