-
Notifications
You must be signed in to change notification settings - Fork 24
Getting Started
Gerald Venzl edited this page Apr 16, 2020
·
7 revisions
- Loading a single CSV file into a database table
- Loading all CSV files from a directory into a database table
- Loading some CSV files from a directory into a database table
Loading a single CSV file into a database table is easy and straight forward.
Example:
$ ./csv2db load \
-f ~/my-csv-file.csv \
-o mysql \
-t STAGING \
-u gerald \
-p supersecret \
-m dbserver1 \
-d mydbSyntax:
$ ./csv2db load \
-f CSV_FILE \
-o DATABASE_TYPE \
-t MY_TABLE \
-u DATABASE_USER \
-p DATABASE_USER_PASSWORD \
-m DATABASE_HOST \
-d DATABASE_NAMEIf you have many files in one directory, you can load them all at once by specifying the directory as the input file. csv2db will iterate over the files in alphabetic order just like they appear if you were to do an ls or dir in the command line.
Example:
$ ./csv2db load \
-f ~/my-csv-files \
-o mysql \
-t STAGING \
-u gerald \
-p supersecret \
-m dbserver1 \
-d mydbSyntax:
$ ./csv2db load \
-f DIRECTORY \
-o DATABASE_TYPE \
-t MY_TABLE \
-u DATABASE_USER \
-p DATABASE_USER_PASSWORD \
-m DATABASE_HOST \
-d DATABASE_NAMEIf you want to load some but not all files inside a directory into a database table you can use wildcard characters in your file name, such as bike*2019*.csv.
Example:
$ ./csv2db load \
-f ~/my-csv-files/bike*2019*.csv \
-o mysql \
-t STAGING \
-u gerald \
-p supersecret \
-m dbserver1 \
-d mydbSyntax:
$ ./csv2db load \
-f DIRECTORY/FILE_PATTERN \
-o DATABASE_TYPE \
-t MY_TABLE \
-u DATABASE_USER \
-p DATABASE_USER_PASSWORD \
-m DATABASE_HOST \
-d DATABASE_NAME