11
2- jsoncsv : easily convert json to csv or xlsx
2+ jsoncsv : easily convert json to csv or xls[x]
33==============================================
44
55.. image :: https://img.shields.io/pypi/v/jsoncsv.svg
@@ -18,12 +18,29 @@ It's simple, and no need user to specify the keys. :)
1818Quick Start :
1919=================
2020
21- cat the raw.json to csv/xls on command line
21+ cat the raw.json to csv/xls use command line tool
22+
23+ each line of raw json text file is a json object.
2224
2325.. code-block :: bash
2426
25- cat raw.json | jsoncsv | mkexcel > output.csv
26- cat raw.json | jsoncsv | mkexcel -t xls > output.xls
27+ # raw json text,(each line is a json object)
28+ # {"id":1, "name":"A"}
29+ # {"id":2, "name":"S"}
30+ cat raw.json | jsoncsv | mkexcel > output.csv
31+ cat raw.json | jsoncsv | mkexcel -t xls > output.xls
32+
33+ a another example
34+
35+ .. code-block :: bash
36+
37+ echo ' {"user":{"id":1,"name":"A"},"week":52}\n{"user":{"id":1,"name":"S"}, "year":2015}' | jsoncsv
38+ # {"user.id": 1, "user.name": "A", "week": 52}
39+ # {"user.id": 1, "user.name": "S", "year": 2015}
40+ echo ' {"user":{"id":1,"name":"A"},"week":52}\n{"user":{"id":1,"name":"S"}, "year":2015}' | jsoncsv| mkexcel
41+ # user.id,user.name,week,year
42+ # 1,A,52,
43+ # 1,S,,2015
2744
2845 or
2946
3249 jsoncsv raw.json expand.json
3350 mkexcel expand.json -t xls output.xls
3451
35- more options see --help.
52+ more options see ` --help ` .
3653
3754.. code-block :: bash
3855
3956 jsoncsv --help
4057 mkexcel --help
4158
42- just expand/restore the json
59+ Install
60+ ================
61+
62+ .. code-block :: bash
63+
64+ pip install jsoncsv
65+
66+
67+ Usage
68+ =================
69+ just expand/restore the json, the expand json is one layer json.
4370
4471.. code-block :: bash
4572
@@ -53,26 +80,17 @@ mkexcel the expanded json (one layer)
5380
5481 mkexcel expand.json output.csv
5582 mkexcel -t xls expand.json > output.xls
56-
57- safe mod
58-
59- .. code-block :: bash
60-
61- cat raw.json| jsoncsv --safe| mkexcel > output.csv
83+ mkexcel -t csv expand.json > output.csv
6284
6385
6486 jsoncsv
6587>>>>>>>>
6688
6789use jsoncsv to expand json files to 1 layer json
6890
69- like this:
70-
7191.. code-block :: bash
7292
73- echo ' {"s":[1,2,{"w":1}]}' | jsoncsv
74- {" s.2.w" : 1," s.0" : 1," s.1" : 2}
75-
93+ jsoncsv raw.json expand.json
7694
7795 -e, --expand
7896-------------
@@ -131,15 +149,12 @@ dump expanded (by **jsoncsv**) json file to csv or xls file
131149
132150.. code-block :: bash
133151
134- mkexcel expand.json -o output.csv
135- cat expand.json| mkexcel > output.csv
136- cat expand.json| mkexcel -t xls > output.xls
137-
152+ mkexcel expand.json output.csv
138153
139154 -t,--type
140155--------------
141156
142- chose dump type in ['csv', 'xls']
157+ chose dump type in ['csv', 'xls'] default is 'csv'
143158
144159.. code-block :: bash
145160
@@ -165,3 +180,9 @@ example:
165180-----------------------------------------
166181
167182wait next version
183+
184+
185+ 3. unicodecsv is not good enough
186+ -----------------------------------------
187+
188+ but better than python strand library csv.
0 commit comments