From 19b79e0cc388effa8917137d7101f69ec0355292 Mon Sep 17 00:00:00 2001 From: anthonydb Date: Sat, 17 Apr 2021 17:43:41 -0400 Subject: [PATCH 1/4] Fix import directory Ch 12. --- Chapter_12/Chapter_12.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Chapter_12/Chapter_12.sql b/Chapter_12/Chapter_12.sql index a2f3bc3..240610c 100644 --- a/Chapter_12/Chapter_12.sql +++ b/Chapter_12/Chapter_12.sql @@ -155,8 +155,7 @@ COPY nyc_yellow_taxi_trips ( improvement_surcharge, total_amount ) --- FROM 'C:\YourDirectory\nyc_yellow_taxi_trips.csv' -FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_12/nyc_yellow_taxi_trips.csv' +FROM 'C:\YourDirectory\nyc_yellow_taxi_trips.csv' WITH (FORMAT CSV, HEADER); CREATE INDEX tpep_pickup_idx From edceaf7be6ce8d012b74bebd3480be8da61087aa Mon Sep 17 00:00:00 2001 From: anthonydb Date: Sat, 17 Apr 2021 17:44:57 -0400 Subject: [PATCH 2/4] Fix import directory Ch 12. --- Chapter_12/Chapter_12.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Chapter_12/Chapter_12.sql b/Chapter_12/Chapter_12.sql index 240610c..135c93f 100644 --- a/Chapter_12/Chapter_12.sql +++ b/Chapter_12/Chapter_12.sql @@ -184,8 +184,7 @@ COPY GROUP BY trip_hour ORDER BY trip_hour ) --- TO 'C:\YourDirectory\hourly_taxi_pickups.csv' -TO '/Users/adebarros/Desktop/hourly_taxi_pickups.csv' +TO 'C:\YourDirectory\hourly_taxi_pickups.csv' WITH (FORMAT CSV, HEADER); -- Listing 12-10: Calculating median trip time by hour From ab479c5d1f10e9977d3811545a3b26e9e8b2684e Mon Sep 17 00:00:00 2001 From: anthonydb Date: Sat, 17 Apr 2021 17:55:54 -0400 Subject: [PATCH 3/4] Fix import directory. --- Chapter_14/Chapter_14.sql | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Chapter_14/Chapter_14.sql b/Chapter_14/Chapter_14.sql index ab4748d..ec8df33 100644 --- a/Chapter_14/Chapter_14.sql +++ b/Chapter_14/Chapter_14.sql @@ -96,8 +96,7 @@ CREATE TABLE crime_reports ( ); COPY crime_reports (original_text) --- FROM 'C:\YourDirectory\crime_reports.csv' -FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_14/crime_reports.csv' +FROM 'C:\YourDirectory\crime_reports.csv' WITH (FORMAT CSV, HEADER OFF, QUOTE '"'); SELECT original_text FROM crime_reports; @@ -271,8 +270,7 @@ CREATE TABLE president_speeches ( ); COPY president_speeches (president, title, speech_date, speech_text) --- FROM 'C:\YourDirectory\president_speeches.csv' -FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_14/president_speeches.csv' +FROM 'C:\YourDirectory\president_speeches.csv' WITH (FORMAT CSV, DELIMITER '|', HEADER OFF, QUOTE '@'); SELECT * FROM president_speeches; From 13e350543084de5d2f8efefdfd2637d1eff01406 Mon Sep 17 00:00:00 2001 From: anthonydb Date: Sat, 17 Apr 2021 18:02:29 -0400 Subject: [PATCH 4/4] Additional shp2pgsql import commands --- Chapter_15/Chapter_15.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Chapter_15/Chapter_15.sql b/Chapter_15/Chapter_15.sql index b15bd80..d885133 100644 --- a/Chapter_15/Chapter_15.sql +++ b/Chapter_15/Chapter_15.sql @@ -171,7 +171,7 @@ ORDER BY miles_from_dt ASC; -- https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html --- Import +-- Import (for use on command line if on macOS or Linux; see Chapter 18) shp2pgsql -I -s 4269 -W LATIN1 tl_2019_us_county.shp us_counties_2019_shp | psql -d analysis -U postgres -- Listing 15-13: Checking the geom column's well-known text representation @@ -245,6 +245,11 @@ WHERE ST_DWithin(sh.geom::geography, -- https://www.census.gov/geo/reference/mtfcc.html -- Here, H3010: A natural flowing waterway + +-- Import (for use on command line if on macOS or Linux; see Chapter 18) +shp2pgsql -I -s 4269 -W LATIN1 tl_2019_35049_linearwater.shp santafe_linearwater_2019 | psql -d analysis -U postgres +shp2pgsql -I -s 4269 -W LATIN1 tl_2019_35049_roads.shp santafe_roads_2019 | psql -d analysis -U postgres + -- Listing 15-18: Using ST_GeometryType() to determine geometry SELECT ST_GeometryType(geom)