Skip to content

Commit

Permalink
Move batting data csv into this repo, reference it appropriately
Browse files Browse the repository at this point in the history
Fixes #5014
  • Loading branch information
josh-heyer committed Nov 29, 2023
1 parent 49dfdf4 commit 102fbca
Show file tree
Hide file tree
Showing 4 changed files with 110,503 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Normally you use the log files to determine the moment in time that you want to
\set PROMPT1 '%`date +"%Y-%m-%dT%H:%M:%S%z"` %/%R%# '
```

For this demonstration, we're just going to import batter data from the [Baseball Databank](https://github.com/chadwickbureau/baseballdatabank), which is in CSV form. While it's easy to import the data using [PostgreSQL's COPY command](https://www.postgresql.org/docs/current/sql-copy.html), we'll need to first define a table to put that data into. Most of the columns are integers, but there are a few strings to consider as well. You can copy and paste this command into your terminal.
For this demonstration, we're just going to import batter data from the [Baseball Databank](https://github.com/cbwinslow/baseballdatabank), which is in CSV form. While it's easy to import the data using [PostgreSQL's COPY command](https://www.postgresql.org/docs/current/sql-copy.html), we'll need to first define a table to put that data into. Most of the columns are integers, but there are a few strings to consider as well. You can copy and paste this command into your terminal.

```sql
CREATE TABLE batters (
Expand Down Expand Up @@ -60,7 +60,7 @@ CREATE TABLE batters (
Now we can populate the table from the internet using the most recent data.

```sql
\COPY batters(playerid,yearid,stint,teamid,lgid,g,ab,r,h,"2b","3b",hr,rbi,sb,cs,bb,so,ibb,hbp,sh,sf,gidp) FROM PROGRAM 'curl "https://raw.githubusercontent.com/chadwickbureau/baseballdatabank/master/core/Batting.csv"' DELIMITER ',' CSV HEADER
\COPY batters(playerid,yearid,stint,teamid,lgid,g,ab,r,h,"2b","3b",hr,rbi,sb,cs,bb,so,ibb,hbp,sh,sf,gidp) FROM PROGRAM 'curl "https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/biganimal/release/free_trial/detail/experiment/data/Batting.csv"' DELIMITER ',' CSV HEADER
```

Just to prove there's data loaded, let's look at the home run leaders for the 1998 season.
Expand Down
Loading

0 comments on commit 102fbca

Please sign in to comment.