Create database table from a CSV
This script scans all the columns and all the rows in a CSV to create a nice table in the csv
database in your local machine.
- Auto detect column type - 3 types currently supported: Integer, Decimal and Text
- Nice column names (still in progress)
- Column collision detection - no two columns are ever names the same.
0.10
- PostgreSQL database
- A database named
csv
- Ruby Version ruby 2.5
- The following Gems: PG, Pry
- Place csv_to_db into your
~/bin
folder and make sure that it's executable. - Ensure that it is accessible in your path.
which csv_to_db
- Find a CSV
- Execute the command:
csv_to_db test.csv
Output:
NOTICE: table "test" does not exist, skipping Database name: csv table name is: test
Sample Table:
Column | Type | Modifiers
-------------+---------+-----------
name | text |
sex | text |
age | integer |
height_in | integer |
weight_lbs | integer |
MIT See license file.