summaryrefslogtreecommitdiff
path: root/system/csv2sql/csv2sql.1
blob: b45e065bc71d50ad4048de0f261557d26674c4d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "CSV2SQL" 1 "2022-07-09" "0.1" "SlackBuilds.org"
.SH NAME
csv2sql \- import data from CSV files into an SQLite database
.\" RST source for csv2sql(1) man page. Convert with:
.
.\" rst2man.py csv2sql.rst > csv2sql.1
.
.\" rst2man.py comes from the SBo development/docutils package.
.
.SH SYNOPSIS
.sp
csv2sql [\fB\-d\fP | \fB\-\-database\fP  \fIdatabase\fP] [\fB\-e\fP | \fB\-\-encoding\fP \fIencoding\fP \fIINPUT\fP:\fIOUTPUT\fP] [\fB\-f\fP | \fB\-\-file\fP \fIfilename\fP] [\fB\-h\fP | \fB\-\-help\fP] [\fB\-t\fP | \fB\-table\fP \fItable\fP] [\fB\-v\fP | \fB\-\-verbose\fP] [\fB\-V\fP | \fB\-\-version\fP]
.SH DESCRIPTION
.sp
\fBcsv2sql\fP is a Ruby script for importing comma\-separated value files
into SQLite.
.sp
The destination table and database will automatically be created if
they do not already exist.
.sp
If the destination table already exists, then \fBcsv2sql\fP assumes that
it contains the same number of columns as the input data. The column
names do not need to match.
.SH OPTIONS
.INDENT 0.0
.TP
.BI \-d\fP,\fB  \-\-database \ DATABASE
Database to import into. Default is \fIcsv2sql.db\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.B \-e, \-\-encoding INPUT:OUTPUT
Input and output encodings. Default is \fIUTF\-8:UTF\-8\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.BI \-f\fP,\fB  \-\-file \ FILENAME
CSV file to import. You can alternately read CSV data from standard input.
.TP
.B  \-h\fP,\fB  \-\-help
Print built\-in help message and exit.
.TP
.BI \-t\fP,\fB  \-\-table \ TABLE
Table to import into. Default is the name of the file being imported from or \fIstdin\fP if CSV data is from standard input. Periods in the filename are replaced with underscores.
.TP
.B  \-v\fP,\fB  \-\-verbose
Print verbose output.
.TP
.B  \-V\fP,\fB  \-\-version
Print version number and exit.
.UNINDENT
.SH NOTE
.sp
\fBcsv2sql\fP assumes the first line of CSV data is a header giving the
column names. If your CSV file doesn\(aqt have column names (if the first
line is just CSV data), you\(aqll have to edit it and add the column
names for \fBcsv2sql\fP to work correctly with it.
.SH EXAMPLES
.INDENT 0.0
.IP 1. 3
Import widgets.csv into the default table (widgets_csv) and database (csv2sql.db):
.INDENT 3.0
.INDENT 3.5
.sp
.nf
.ft C
csv2sql \-f widgets.csv
.ft P
.fi
.UNINDENT
.UNINDENT
.IP 2. 3
Import standard input into the "foo" table within the "bar.db" database:
.INDENT 3.0
.INDENT 3.5
.sp
.nf
.ft C
cat widgets.csv | csv2sql \-t foo \-d bar.db
.ft P
.fi
.UNINDENT
.UNINDENT
.IP 3. 3
Import products.csv and more\-products.csv into the "products" table within the default database (csv2sql.db):
.INDENT 3.0
.INDENT 3.5
.sp
.nf
.ft C
csv2sql \-f products.csv \-t products
csv2sql \-f more\-products.csv \-t products
.ft P
.fi
.UNINDENT
.UNINDENT
.IP 4. 3
Export data from SQLite sorted by the "ProductName" column to output.csv:
.INDENT 3.0
.INDENT 3.5
.sp
.nf
.ft C
sqlite3 \-header \-csv csv2sql.db "SELECT * FROM products ORDER BY ProductName" > output.csv
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT
.SH COPYRIGHT
.sp
\fBcsv2sql\fP is open source software released under the MIT License. See:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
http://www.opensource.org/licenses/MIT
.ft P
.fi
.UNINDENT
.UNINDENT
.SH AUTHORS
.sp
\fBcsv2sql\fP was written by Matt Rideout.
.sp
This man page written for the SlackBuilds.org project
by B. Watson, and is licensed under the WTFPL.
.SH SEE ALSO
.sp
The csv2sql homepage: \fI\%http://csv2sql.org/\fP
.\" Generated by docutils manpage writer.
.