vinay20045/json-to-csv
소개
Nested JSON to CSV Converter
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originaljson-to-csv
Nested JSON to CSV Converter.
This python script converts valid, preformatted JSON to CSV which can be opened in excel and other similar applications. This script can handle nested json with multiple objects and arrays. Please see the explanation below and the sample files to understand how this works. It can handle non similar objects too. But, more the similarity of the objects, prettier the output.
Written in Python 2.7. Last tested in Python 3.6.3.
Usage
python /path/to/json_to_csv.py node json_in_file_path csv_out_file_path
Source Specification
The script expects the json to be given via a file containing
- A valid JSON
- The JSON can be an
ArrayofnodeObjectEx:-
{
"node":[
{
"item_1":"value_11",
"item_2":"value_12",
"item_3":"value_13",
"item_4":["sub_value_14", "sub_value_15"],
"item_5":{
"sub_item_1":"sub_item_value_11",
"sub_item_2":["sub_item_value_12", "sub_item_value_13"]
}
},
{
"item_1":"value_21",
"item_2":"value_22",
"item_4":["sub_value_24", "sub_value_25"],
"item_5":{
"sub_item_1":"sub_item_value_21",
"sub_item_2":["sub_item_value_22", "sub_item_value_23"]
}
}
]
}
- The JSON can be a
listofdictionaries - If your JSON is a list of dictionaries, the first argument
nodecan be any relevant string
[
{
"item_1":"value_11",
"item_2":"value_12",
"item_3":"value_13",
"item_4":["sub_value_14", "sub_value_15"],
"item_5":{
"sub_item_1":"sub_item_value_11",
"sub_item_2":["sub_item_value_12", "sub_item_value_13"]
}
},
{
"item_1":"value_21",
"item_2":"value_22",
"item_4":["sub_value_24", "sub_value_25"],
"item_5":{
"sub_item_1":"sub_item_value_21",
"sub_item_2":["sub_item_value_22", "sub_item_value_23"]
}
}
]
Gotchas
I have written a JSON generator which will take care of encoding issues and generate a valid JSON for this tool. However, If you find yourself in the character encoding hell, drop me a mail and I will add support for this This is now fixed.
Read More
Visit converting nested json to csv post on my blog to read more about this script.
관련 프로젝트 살펴보기
불러오는 중…