The absolute easiest way to get a CSV into a postgresql table is to use ogr2ogr with AUTODETECT_TYPE=YES.
I learned a while back that this is what cartoDB uses to import your CSV into postgis (with a lot of other parameters added)
ogr2ogr -f PostgreSQL PG:"host=localhost user=postgres dbname=postgres password=password" docs.csv -oo AUTODETECT_TYPE=YES
agreed. Works well.
Furthermore, if you wanted to only load certain columns from the CSV, you could pass an
-sql
flag like this:PostgreSQL PG:"host=localhost user=postgres dbname=postgres password=password" docs.csv -oo AUTODETECT_TYPE=YES -sql "SELECT col1, col2 FROM docs"
Notice how you must omit the file extension (.csv) from the SQL query.