alingse / jsoncsv Goto Github PK
View Code? Open in Web Editor NEWa command tool easily convert json file to csv or xlsx
Home Page: https://jsoncsv-web.vercel.app/
License: Apache License 2.0
a command tool easily convert json file to csv or xlsx
Home Page: https://jsoncsv-web.vercel.app/
License: Apache License 2.0
When I use the command line conver the following lines:
{"english": "Slowly and not without struggle, America began to listen.", "chinese": "美国缓慢地开始倾听,但并非没有艰难曲折。"}
{"english": "I didn't own a Thesaurus until four years ago and I use a small Webster's dictionary that I'd bought at K-Mart for 89 cents.", "chinese": "直到四年前我才有了一本词典。我使用的是用89美分在K市场里买来的一本韦氏小词典。我从来不使用单词处理程序。"}
{"english": "portlet, you must write three short deployment descriptors: web.xml, portlet.xml, and geronimo-web.xml. (Some of these may have been generated by your IDE.)", "chinese": "portlet 之后,您必须编写三个简短的部署描述符:web.xml、portlet.xml 和 geronimo-web.xml(这其中的一些文件可能已经由 IDE 生成)。"}
I get the result in an inversed order:
chinese,english
美国缓慢地开始倾听,但并非没有艰难曲折。,"Slowly and not without struggle, America began to listen."
直到四年前我才有了一本词典。我使用的是用89美分在K市场里买来的一本韦氏小词典。我从来不使用单词处理程序。,I didn't own a Thesaurus until four years ago and I use a small Webster's dictionary that I'd bought at K-Mart for 89 cents.
portlet 之后,您必须编写三个简短的部署描述符:web.xml、portlet.xml 和 geronimo-web.xml(这其中的一些文件可能已经由 IDE 生成)。,"portlet, you must write three short deployment descriptors: web.xml, portlet.xml, and geronimo-web.xml. (Some of these may have been generated by your IDE.)"
虽然影响不大,但是折腾了我一小会。希望在manual里提一下。
ubuntu 16.04
cat in.json | jsoncsv | mkexcel > out.csv
ERROR
Traceback (most recent call last):
File "/usr/local/bin/jsoncsv", line 9, in
load_entry_point('jsoncsv==2.0.8', 'console_scripts', 'jsoncsv')()
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "build/bdist.linux-x86_64/egg/jsoncsv/main.py", line 50, in jsoncsv
File "/usr/lib/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting object: line 1 column 3 (char 2)
THANKS
see #27
转换逻辑略微调整就可以支持直接填数组啦,希望可以支持一下
// ...
$("#transform").click((function() {
const t = $("#inputs").val();
const e = JSON.parse(t.trim())
// , e = t.trim().split("\n");
if ("" == t)
return;
const o = e;
// for (const t of e) {
// const n = JSON.parse(t);
// o.push(n)
// }
// ...
}))
Am using centOS 7 and using python 2.7. Am getting following exception when try to convert json to CSV
[root@SIQ4L_6709 jsoncsv-2.2.4]# cat exportAttributes_matter.json | jsoncsv | mkexcel > output.csv
Traceback (most recent call last):
File "/usr/bin/jsoncsv", line 9, in
load_entry_point('jsoncsv==2.2.4', 'console_scripts', 'jsoncsv')()
File "/usr/lib/python2.7/site-packages/click-7.1.1-py2.7.egg/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/click-7.1.1-py2.7.egg/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/site-packages/click-7.1.1-py2.7.egg/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.7/site-packages/click-7.1.1-py2.7.egg/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "build/bdist.linux-x86_64/egg/jsoncsv/main.py", line 60, in jsoncsv
File "build/bdist.linux-x86_64/egg/jsoncsv/jsontool.py", line 160, in convert_json
File "build/bdist.linux-x86_64/egg/jsoncsv/jsontool.py", line 145, in gen_objs
File "/usr/lib64/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting object: line 1 column 2 (char 1)
你好,感谢你分享这个repo。请问如何把key作为csv文件中的header。
{"abstract": "xxxxx", "authors": ["a", "b", "c"], "references": ["1", "2"], "title": "aaaaa"}
abstract authors1 author2 author3 references1 reference2 title
xxxxx a b c 1 2 aaaaa
谢谢!
echo '{"": {}}'|mkexcel -t xls > x.xls
-------
raise Exception("Unexpected data type %r" % type(label))
Exception: Unexpected data type <class 'dict'>
echo '{"": {}}'|mkexcel -t csv 1 ↵
""
""
TODO:
C:\Users\Roy>pip install jsoncsv
Collecting jsoncsv
Downloading https://files.pythonhosted.org/packages/a1/31/eb4c78c2f9a57ac29ff6
2b12a3c7a5cb48b762b7c0362b6c4a152b721d7c/jsoncsv-2.0.7.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Roy\AppData\Local\Temp\pip-install-jblltyy7\jsoncsv\setup.p
y", line 12, in
readme = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 1115: ill
egal multibyte sequence
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Roy\AppD
ata\Local\Temp\pip-install-jblltyy7\jsoncsv\
编程新人。python3(spider)+windows下使用,最后一行错误SyntaxError: invalid syntax
code如下:
import os
import sys
import json
import jsoncsv
file_dir = '../data/raw/103_course_content/02_course_bought_together/9287.json'
cat 9287.json |jsoncsv |mkexcel > output.csv
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.