mirror of
https://github.com/dimitri/pgloader.git
synced 2026-01-22 15:41:03 +01:00
39 lines
1.2 KiB
Fish
39 lines
1.2 KiB
Fish
LOAD ARCHIVE
|
|
FROM http://www.census.gov/geo/maps-data/data/docs/gazetteer/places2k.zip
|
|
INTO postgresql:///pgloader
|
|
|
|
BEFORE LOAD DO
|
|
$$ drop table if exists places; $$,
|
|
$$ create table places
|
|
(
|
|
usps char(2) not null,
|
|
fips char(2) not null,
|
|
fips_code char(5),
|
|
"LocationName" varchar(64)
|
|
);
|
|
$$
|
|
|
|
LOAD FIXED
|
|
FROM FILENAME MATCHING ~/places2k.txt/
|
|
WITH ENCODING latin1
|
|
(
|
|
-- name start length
|
|
usps 0 2,
|
|
fips 2 2,
|
|
fips_code 4 5,
|
|
"LocationName" 9 64,
|
|
p 73 9,
|
|
h 82 9,
|
|
land 91 14,
|
|
water 105 14,
|
|
ldm 119 14,
|
|
wtm 131 14,
|
|
lat 143 10,
|
|
long 153 11
|
|
)
|
|
INTO postgresql:///pgloader?places
|
|
(
|
|
usps, fips, fips_code,
|
|
"LocationName" text using (right-trim LocationName)
|
|
);
|