MJN All Blog Cheatsheets Elasticsearch GCP JS LinuxBash Misc Notes Other ShortcutKeys / - Search

Home / Other / Postgres / Load CSV File Into Postgres


Load CSV File Into Postgres

Create your table

CREATE TABLE zip_codes 
( zip CHAR(5)
, latitude DOUBLE PRECISION
, longitude DOUBLE PRECISION
, city VARCHAR
, state CHAR(2)
, county VARCHAR
, zip_class VARCHAR );

Copy data from your CSV file to the table:

\copy zip_codes FROM '/path/to/csv/ZIP_CODES.txt' DELIMITER ',' CSV

You can also specify the columns to read:

\copy zip_codes(ZIP,CITY,STATE) FROM '/path/to/csv/ZIP_CODES.txt' DELIMITER ',' CSV

This page was generated by GitHub Pages. Page last modified: 20/09/07 12:31