Skip to content

Commit 472ceef

Browse files
author
Marcin kotynia
committed
2 parents 1108772 + 5f9b7f2 commit 472ceef

2 files changed

Lines changed: 56 additions & 10 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 Marcin
3+
Copyright (c) 2016 Marcin Kotynia
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,75 @@
11
# CSVtoSQL
22

3+
## Description
4+
35
This little dirty application will help you to convert CSV file into set of SQL commands.
46
To do that you can
57

68
- provide input file in csv format
79
- define template file which store template for each row
8-
- CSVtoSQL till generate ouput file where set of commands will be saved > later you can use for example osql to execute this statements
10+
- CSVtoSQL will generate ouput file where set of commands will be saved
11+
- later you can use for example osql to execute this statements
912

13+
## Options
1014

15+
~~~
1116
Options:
12-
1317
-i, --input (Default: input.csv) CSV file to be processedv
1418
1519
-o, --output (Default: output.sql) FILE with Output
1620
17-
-t, --template Required. (Default: template.txt) FILE with template .
18-
Sample Template text insert into test (xxx,yyy) values
19-
( {1},{2})
21+
-t, --template Required. (Default: template.txt) Template file where
22+
data will be replaced form input file . Sample Template
23+
text insert into mytable (column1,column2) values
24+
({0},{1})
2025
21-
-s, --csvseparator (Default: ,) CSV Separator
26+
-s, --csvseparator (Default: ,) CSV Separator any char or - tabulator
27+
28+
-l, --line (Default: 2) Start form Line
2229
2330
--help Display this help screen.
31+
~~~
2432

25-
26-
27-
SAMPLE Command line
2833

34+
## SAMPLE Command line
35+
36+
Use tab character as column separator
37+
~~~
2938
CSVtoSQL.exe -t template.txt -i input.csv -s \t
39+
~~~
40+
41+
All parameters provided
42+
~~~
43+
CSVtoSQL.exe -t mytemplate.txt -i data.csv -s \t -o myoutputfile.sql -l 4
44+
~~~
45+
46+
## SAMPLE FLOW
47+
Each row and column in csv is processed using temaplte file
48+
49+
### Sample data file data.csv
50+
~~~
51+
header,header
52+
column1row1,column2row1
53+
column1row2,column2row2
54+
column1row3,column2row3
55+
~~~
56+
57+
### sample template mytemplate.txt
58+
~~~
59+
insert into mytable (column1,column2) values ('{0}','{1}');
60+
~~~
61+
62+
###Command
63+
~~~
64+
CSVtoSQL.exe -t mytemplate.txt -i data.csv
65+
~~~
66+
67+
###RESULT output.sql
68+
~~~
69+
insert into mytable (column1,column2) values ('column1row1','column2row1');
70+
insert into mytable (column1,column2) values ('column1row2','column2row2');
71+
insert into mytable (column1,column2) values ('column1row3','column2row3');
72+
~~~
73+
74+
75+

0 commit comments

Comments
 (0)