csv2psql 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +82 -3
- data/data/census_SFOH_2010.csv +981 -0
- data/lib/csv2psql/analyzer/types/base_analyzer.rb +45 -1
- data/lib/csv2psql/analyzer/types/boolean.rb +1 -1
- data/lib/csv2psql/analyzer/types/null.rb +1 -1
- data/lib/csv2psql/analyzer/types/string.rb +1 -1
- data/lib/csv2psql/analyzer/types/uuid.rb +1 -1
- data/lib/csv2psql/cli/app.rb +0 -46
- data/lib/csv2psql/cli/cmd/analyze_cmd.rb +2 -1
- data/lib/csv2psql/cli/cmd/schema_cmd.rb +85 -0
- data/lib/csv2psql/convert/convert.rb +7 -2
- data/lib/csv2psql/generator/generator.rb +13 -11
- data/lib/csv2psql/processor/processor.rb +19 -6
- data/lib/csv2psql/schema/schema_generator.rb +48 -0
- data/lib/csv2psql/version.rb +2 -2
- data/templates/schema.sql.erb +11 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 403c981b7b0dda9cef22593e30515652936f4bd9
|
4
|
+
data.tar.gz: 87bf7ebe76a2d613489f3a3358262cd13c236451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9011ba3f4fa5af974a392799f0c056ff0c96238125d80d12729eb5a24d1766d7320058958600ba65f392c013e792c46387e4e1c12003657c87335ad8ad105cf6
|
7
|
+
data.tar.gz: 375eed254a3079090c6f5250c36eba80249c8cbc486574f7472bb969eb30f456a9f717918e46cb212cee9e6aa93d7d83ad6db74e8b010b8dbe46432100f17856
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ csv2psql convert data/sample.csv
|
|
48
48
|
csv2psql help
|
49
49
|
|
50
50
|
NAME
|
51
|
-
csv2psql - csv2psql 0.0.
|
51
|
+
csv2psql - csv2psql 0.0.12 (Codename: Prudent owl)
|
52
52
|
|
53
53
|
SYNOPSIS
|
54
54
|
csv2psql [global options] command [command options] [arguments...]
|
@@ -57,14 +57,17 @@ GLOBAL OPTIONS
|
|
57
57
|
-d, --delimiter=arg - Column delimiter (default: ,)
|
58
58
|
-h, --[no-]header - Header row included (default: enabled)
|
59
59
|
--help - Show this message
|
60
|
+
-l, --limit=arg - How many rows process (default: -1)
|
60
61
|
-q, --quote=arg - Quoting character (default: ")
|
61
|
-
-s, --separator=arg - Line separator (default:
|
62
|
+
-s, --separator=arg - Line separator (default: none)
|
63
|
+
--skip=arg - How many rows skip (default: -1)
|
62
64
|
|
63
65
|
COMMANDS
|
64
66
|
analyze - Analyze csv file
|
65
67
|
convert - Convert csv file
|
66
68
|
help - Shows a list of commands or help for one command
|
67
|
-
|
69
|
+
schema - Generate schema for file
|
70
|
+
version - Print version info```
|
68
71
|
```
|
69
72
|
|
70
73
|
**Analyze help**
|
@@ -101,6 +104,21 @@ COMMAND OPTIONS
|
|
101
104
|
--[no-]truncate-table - Truncate SQL Table before inserts
|
102
105
|
```
|
103
106
|
|
107
|
+
**Schema help**
|
108
|
+
|
109
|
+
```
|
110
|
+
csv2psql help schema
|
111
|
+
|
112
|
+
NAME
|
113
|
+
schema - Generate schema for file
|
114
|
+
|
115
|
+
SYNOPSIS
|
116
|
+
csv2psql [global options] schema [command options]
|
117
|
+
|
118
|
+
COMMAND OPTIONS
|
119
|
+
-f, --format=arg - Output format (default: json)
|
120
|
+
```
|
121
|
+
|
104
122
|
## Example
|
105
123
|
|
106
124
|
**Input CSV**
|
@@ -220,6 +238,67 @@ csv2psql analyze --format=table tmp/sfpd_incident_2013.csv
|
|
220
238
|
+------------+--------+-----------+---------+------+--------+------+
|
221
239
|
```
|
222
240
|
|
241
|
+
**Schema guess**
|
242
|
+
|
243
|
+
```
|
244
|
+
csv2psql schema -f table ./data/census_SFOH_2010.csv
|
245
|
+
|
246
|
+
+-------------------------------------------------+---------+---------+
|
247
|
+
| ./data/census_SFOH_2010.csv |
|
248
|
+
+-------------------------------------------------+---------+---------+
|
249
|
+
| column | type | null |
|
250
|
+
+-------------------------------------------------+---------+---------+
|
251
|
+
| MSA | text | false |
|
252
|
+
| Tract ID | bigint | false |
|
253
|
+
| White Alone | bigint | false |
|
254
|
+
| Black or African American alone | bigint | false |
|
255
|
+
| Asian alone | bigint | false |
|
256
|
+
| Family Households | bigint | false |
|
257
|
+
| Nonfamily Households | bigint | false |
|
258
|
+
| Household income: < 10k | bigint | false |
|
259
|
+
| Household income: 10-15k | bigint | false |
|
260
|
+
| Household income: 15-20k | bigint | false |
|
261
|
+
| Household income: 20-25k | bigint | false |
|
262
|
+
| Household income: 25-30k | bigint | false |
|
263
|
+
| Household income: 30-35k | bigint | false |
|
264
|
+
| Household income: 35-40k | bigint | false |
|
265
|
+
| Household income: 40-45k | bigint | false |
|
266
|
+
| Household income: 45-50k | bigint | false |
|
267
|
+
| Household income: 50-60k | bigint | false |
|
268
|
+
| Household income: 60-75k | bigint | false |
|
269
|
+
| Household income: 75-100k | bigint | false |
|
270
|
+
| Household income: 100-125k | bigint | false |
|
271
|
+
| Household income: 125-150k | bigint | false |
|
272
|
+
| Household income: 150-200k | bigint | false |
|
273
|
+
| Household income: > 200k | bigint | false |
|
274
|
+
| With wage or salary income | bigint | false |
|
275
|
+
| No wage or salary income | bigint | false |
|
276
|
+
| With self-employment income | bigint | false |
|
277
|
+
| No self-employment income | bigint | false |
|
278
|
+
| With interest dividends or net rental income | bigint | false |
|
279
|
+
| No interest dividends or net rental income | bigint | false |
|
280
|
+
| With Social Security income | bigint | false |
|
281
|
+
| No Social Security income | bigint | false |
|
282
|
+
| With Supplemental Security Income (SSI) | bigint | false |
|
283
|
+
| No Supplemental Security Income (SSI) | bigint | false |
|
284
|
+
| With public assistance income | bigint | false |
|
285
|
+
| No public assistance income | bigint | false |
|
286
|
+
| With cash public assistance or Food Stamps/SNAP | bigint | false |
|
287
|
+
| No cash public assistance or Food Stamps/SNAP | bigint | false |
|
288
|
+
| With retirement income | bigint | false |
|
289
|
+
| No retirement income | bigint | false |
|
290
|
+
| Per capita income (2010 dollars) | bigint | true |
|
291
|
+
| Housing units | bigint | false |
|
292
|
+
| Occupancy status: Occupied | bigint | false |
|
293
|
+
| Occupancy status: Vacant | bigint | false |
|
294
|
+
| Housing tenure: Owner-occupied | bigint | false |
|
295
|
+
| Housing tenure: Renter-occupied | bigint | false |
|
296
|
+
| Median number of rooms | decimal | true |
|
297
|
+
| Median gross rent (dollars) | bigint | true |
|
298
|
+
| Median value for owner-occupied housing | bigint | true |
|
299
|
+
+-------------------------------------------------+---------+---------+
|
300
|
+
```
|
301
|
+
|
223
302
|
## Contributing to csv2psql
|
224
303
|
|
225
304
|
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|