Simple CSV file import
You have a CSV file called “data.csv”. It has a header line, and is delimited using “;”. You want to import it into Postgres and a table called “your_table”:
Create the database table. Set column-types so the string fields in the CSV file, can be cast to values in columns.
CREATE TABLE your_table ( -- Your columns );
Execute COPY command:
COPY your_table FROM '/path/to/csv/file/data.csv' WITH DELIMITER ';' CSV HEADER;
If the data is geospatial
Another option is using ogr2ogr, which has a CSV driver. The COPY command could be faster.
If you have point data, check out this howto: Loading Point Data from a CSV File into PostGIS