Pgcsv is a project mainly written in PYTHON and SHELL, based on the MIT license.
Python module and command-line utility for loading CSV files into PostgreSQL tables
pgcsv is both a Python module and command-line utility for loading delimited data from text files into database tables.
If you're using a version of Python earlier than 2.7, you'll need to install the argparse module manaully.
You can execute pgcsv --help
for a list of all options. Basic usage:
pgcsv -S schema -t table -f csvfile connstring
Where connstring
is a libpq-style connection string.
By default, pgcsv will do the following:
You can execute either via the pgcsv
script that is installed to your system PATH,
or via python -m pgcsv
.
If you deal with data that sometimes throws around errant null bytes, use the
included csvclean script to strip them out. Or just run sed -i -e 's/\x00//g' filename
.