1CSVJSON(1)                          csvkit                          CSVJSON(1)
2
3
4

NAME

6       csvjson - csvjson Documentation
7

DESCRIPTION

9       Converts a CSV file into JSON or GeoJSON (depending on flags):
10
11          usage: csvjson [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
12                         [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-L LOCALE]
13                         [-S] [--blanks] [--date-format DATE_FORMAT]
14                         [--datetime-format DATETIME_FORMAT] [-H] [-K SKIP_LINES] [-v]
15                         [-l] [--zero] [-V] [-i INDENT] [-k KEY] [--lat LAT] [--lon LON]
16                         [--crs CRS] [--stream] [-y SNIFF_LIMIT] [-I]
17                         [FILE]
18
19          Convert a CSV file into JSON (or GeoJSON).
20
21          positional arguments:
22            FILE                  The CSV file to operate on. If omitted, will accept
23                                  input on STDIN.
24
25          optional arguments:
26            -h, --help            show this help message and exit
27            -i INDENT, --indent INDENT
28                                  Indent the output JSON this many spaces. Disabled by
29                                  default.
30            -k KEY, --key KEY     Output JSON as an array of objects keyed by a given
31                                  column, KEY, rather than as a list. All values in the
32                                  column must be unique. If --lat and --lon are also
33                                  specified, this column will be used as GeoJSON Feature
34                                  ID.
35            --lat LAT             A column index or name containing a latitude. Output
36                                  will be GeoJSON instead of JSON. Only valid if --lon
37                                  is also specified.
38            --lon LON             A column index or name containing a longitude. Output
39                                  will be GeoJSON instead of JSON. Only valid if --lat
40                                  is also specified.
41            --crs CRS             A coordinate reference system string to be included
42                                  with GeoJSON output. Only valid if --lat and --lon are
43                                  also specified.
44            --stream              Output JSON as a stream of newline-separated objects,
45                                  rather than an as an array.
46            -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT
47                                  Limit CSV dialect sniffing to the specified number of
48                                  bytes. Specify "0" to disable sniffing entirely.
49            -I, --no-inference    Disable type inference (and --locale, --date-format,
50                                  --datetime-format) when parsing CSV input.
51
52       See also: ../common_arguments.
53

EXAMPLES

55       Convert  veteran’s  education  dataset to JSON keyed by state abbrevia‐
56       tion:
57
58          csvjson -k "State Abbreviate" -i 4 examples/realdata/FY09_EDU_Recipients_by_State.csv
59
60       Results in a JSON document like:
61
62          {
63              [...]
64              "WA": {
65                  "State Name": "WASHINGTON",
66                  "State Abbreviate": "WA",
67                  "Code": 53.0,
68                  "Montgomery GI Bill-Active Duty": 7969.0,
69                  "Montgomery GI Bill- Selective Reserve": 769.0,
70                  "Dependents' Educational Assistance": 2192.0,
71                  "Reserve Educational Assistance Program": 549.0,
72                  "Post-Vietnam Era Veteran's Educational Assistance Program": 13.0,
73                  "TOTAL": 11492.0,
74                  "": null
75              },
76              [...]
77          }
78
79       Converting locations of public art into GeoJSON:
80
81          csvjson --lat latitude --lon longitude --k slug --crs EPSG:4269 -i 4 examples/test_geo.csv
82
83       Results in a GeoJSON document like:
84
85          {
86              "type": "FeatureCollection",
87              "bbox": [
88                  -95.334619,
89                  32.299076986939205,
90                  -95.250699,
91                  32.351434
92              ],
93              "crs": {
94                  "type": "name",
95                  "properties": {
96                      "name": "EPSG:4269"
97                  }
98              },
99              "features": [
100                  {
101                      "type": "Feature",
102                      "id": "dcl",
103                      "geometry": {
104                          "type": "Point",
105                          "coordinates": [
106                              -95.30181,
107                              32.35066
108                          ]
109                      },
110                      "properties": {
111                          "title": "Downtown Coffee Lounge",
112                          "artist": null,
113                          "description": "In addition to being the only coffee shop in downtown Tyler, DCL also features regular exhibitions of work by local artists.",
114                          "install_date": null,
115                          "address": "200 West Erwin Street",
116                          "type": "Gallery",
117                          "photo_url": null,
118                          "photo_credit": null,
119                          "last_seen_date": "2012-03-30"
120                      }
121                  },
122                  [...]
123              ],
124              "crs": {
125                  "type": "name",
126                  "properties": {
127                      "name": "EPSG:4269"
128                  }
129              }
130          }
131

AUTHOR

133       Christopher Groskopf
134
136       2016, Christopher Groskopf
137
138
139
140
1411.0.3                            Jul 15, 2018                       CSVJSON(1)
Impressum