Loading spatial data into MySQL with LOAD DATA INFILE

(Redirected from Loading spatial data into MySQL with LOAD DATA INFILE)

Just a note for my future reference: importing an Excel CSV into MySQL. The WKT column has been constructed by hand to be POINT(lng lat) and the CSV contains headers.

LOAD DATA INFILE '/full\_path/to/file-on-server.csv'
REPLACE INTO TABLE the\_table COLUMNS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' IGNORE 1 ROWS (name,description,@geographic\_location)
SET geographic\_location = GeomFromText(@geographic_location);


Retrieved from ‘https://samwilson.id.au/index.php?title=Loading_spatial_data_into_MySQL_with_LOAD_DATA_INFILE&oldid=2561