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            --type TYPE           A column index or name containing a GeoJSON type.
42                                  Output will be GeoJSON instead of JSON. Only valid if
43                                  --lat and --lon are also specified.
44            --geometry GEOMETRY   A column index or name containing a GeoJSON geometry.
45                                  Output will be GeoJSON instead of JSON. Only valid if
46                                  --lat and --lon are also specified.
47            --crs CRS             A coordinate reference system string to be included
48                                  with GeoJSON output. Only valid if --lat and --lon are
49                                  also specified.
50            --no-bbox             Disable the calculation of a bounding box.
51            --stream              Output JSON as a stream of newline-separated objects,
52                                  rather than an as an array.
53            -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT
54                                  Limit CSV dialect sniffing to the specified number of
55                                  bytes. Specify "0" to disable sniffing entirely.
56            -I, --no-inference    Disable type inference (and --locale, --date-format,
57                                  --datetime-format) when parsing CSV input.
58
59       See also: ../common_arguments.
60

EXAMPLES

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

AUTHOR

140       Christopher Groskopf
141
143       2019, Christopher Groskopf
144
145
146
147
1481.0.4                            Aug 01, 2019                       CSVJSON(1)
Impressum