擅长:python、mysql、java
<p>试试这样的。</p>
<pre><code>json_dict = {
"Person" : [{"name":"Greg","age":"35","car":["honda civic","ford focus"]},
{"name":"Steve","age":"28", "car":["mazda 323", "toyota camry"]}]
}
for entity in json_dict:
csv_file = open('%s.csv' % entity, 'wb')
headers = a[entity][0].keys()
csv_writer = csv.DictWriter(csv_file, headers)
map(csv_writer.writerow, json_dict[entity])
csv_file.close()
</code></pre>
<p>#现在您有了json到csv的格式化文件,可以使用awk</p>
<pre><code>awk -F , '{print NR ", " $2 ", " $3 }' Person.csv > person.csv
</code></pre>
<p>。。。</p>