I'm trying to load GTFS files (comma separated text files) to a MySQL database. MySQL Workbench Import Wizard doesn't work. I copied agency.txt
file to agency.csv
and select it with the wizard. Went through all the steps; everything was a green checkmark but It said '0 records imported' at the end. No errors, no warnings.
I use mysql shell.
This is my file:
>>head -2 agency.csv
agency_name,agency_url,agency_timezone,agency_lang,agency_phone,agency_fare_url
Chicago Transit Authority,http://transitchicago.com,America/Chicago,en,1-888-YOURCTA,http://www.transitchicago.com/travel_information/fares/default.aspx
This is my sql script to create a table and load the data:
CREATE TABLE agency (
agency_name VARCHAR(255) character set utf8,
agency_id VARCHAR(255) character set utf8,
agency_url VARCHAR(255) character set utf8,
agency_timezone VARCHAR(255) character set utf8
);
LOAD DATA LOCAL INFILE '/cta/agency.csv' INTO TABLE agency
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(agency_name,@vagency_id,agency_url,agency_timezone)
SET agency_id = IF(agency_id IS NULL, agency_name, @vagency_id);
and this is what is loaded to the table:
mysql> select * from agency;
+---------------------------+---------------------------+----------------------------+-----------------+
| agency_name | agency_id | agency_url | agency_timezone |
+---------------------------+---------------------------+----------------------------+-----------------+
| Chicago Transit Authority | Chicago Transit Authority | America/Chicago | en |
Note that Agency_url in the table is America/Chicago (timezone not a url).
I am not very experienced in sql technologies but I think it shouldn't be so hard to put data to a database. Can someone tell me 1. Why is this happening? 2. How to fix it?