Package Exports
- csv-to-pg
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (csv-to-pg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
csv-to-pg 
Create PostgreSQL statements from CSV files
Installation
npm install -g csv-to-pgUsage
The idea for this library was to solve complex CSV scenarios, so currently each CSV requires a config file.
config
Here is an example of a config.yaml that we can use to parse a csv that has no headers, and uses tab-delimited elements:
input: "./myfile.tsv"
output: "./myfile.sql"
schema: myschema
table: mytable
delimeter: "\t"
headers: # order of the headers
- feature
- category
- days
- start
- end
fields:
feature: text
category: text
days: int
start: date
end:
type: date
cast: date # explicitly cast to a date typeYou can also use JS files or JSON. If you use JS, you can also create ASTs for super custom inserts (read tests).
run it!
Once you have a config file, simply call it and point to the config:
csv2pg ./config.yaml