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 as piped data via 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 object keyed by a given column, KEY,
31                                  rather than as an array. All column values must be
32                                  unique. If --lat and --lon are specified, this column
33                                  is used as the GeoJSON Feature ID.
34            --lat LAT             A column index or name containing a latitude. Output
35                                  will be GeoJSON instead of JSON. Requires --lon.
36            --lon LON             A column index or name containing a longitude. Output
37                                  will be GeoJSON instead of JSON. Requires --lat.
38            --type TYPE           A column index or name containing a GeoJSON type.
39                                  Output will be GeoJSON instead of JSON. Requires --lat
40                                  and --lon.
41            --geometry GEOMETRY   A column index or name containing a GeoJSON geometry.
42                                  Output will be GeoJSON instead of JSON. Requires --lat
43                                  and --lon.
44            --crs CRS             A coordinate reference system string to be included
45                                  with GeoJSON output. Requires --lat and --lon.
46            --no-bbox             Disable the calculation of a bounding box.
47            --stream              Output JSON as a stream of newline-separated objects,
48                                  rather than an as an array.
49            -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT
50                                  Limit CSV dialect sniffing to the specified number of
51                                  bytes. Specify "0" to disable sniffing.
52            -I, --no-inference    Disable type inference (and --locale, --date-format,
53                                  --datetime-format) when parsing CSV input.
54
55       See also: Arguments common to all tools.
56

EXAMPLES

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

AUTHOR

136       Christopher Groskopf
137
139       2022, Christopher Groskopf
140
141
142
143
1441.0.7                            Jul 22, 2022                       CSVJSON(1)
Impressum