ziemekwolski / csv_to_db

Create database table from a CSV

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSV to DB

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.

csv to db screen shot

Features

  1. Auto detect column type - 3 types currently supported: Integer, Decimal and Text
  2. Nice column names (still in progress)
  3. Column collision detection - no two columns are ever names the same.

Version

0.10

Requirements

  1. PostgreSQL database
  2. A database named csv
  3. Ruby Version ruby 2.5
  4. The following Gems: PG, Pry

Installation

  1. Place csv_to_db into your ~/bin folder and make sure that it's executable.
  2. Ensure that it is accessible in your path. which csv_to_db

How to use

  1. Find a CSV
  2. 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 |

License

MIT See license file.

About

Create database table from a CSV

License:MIT License


Languages

Language:Ruby 100.0%