Python 将数据从json文件打印到csv文件
当我将数据从json文件打印到csv文件时,它不会打印在不同的列中。。 这是我的密码Python 将数据从json文件打印到csv文件,python,csv,python-3.x,Python,Csv,Python 3.x,当我将数据从json文件打印到csv文件时,它不会打印在不同的列中。。 这是我的密码 import json import urllib import csv def main(): f1 = open('tweet-stream.json','r') Outputfile =open('newdata3.csv', 'w') count = 0 for line in f1: d = json.loads(line) lang = d["user"]
import json
import urllib
import csv
def main():
f1 = open('tweet-stream.json','r')
Outputfile =open('newdata3.csv', 'w')
count = 0
for line in f1:
d = json.loads(line)
lang = d["user"]["lang"]
status_count = d["user"]["statuses_count"]
print >>Outputfile,"Language: " + lang + "Status_Count" +str(status_count)
if __name__ == "__main__":
main()
f1 = json.load(open(tweet-stream.json', 'r'))
fileWriter = csv.writer(file1 , delimiter=",",quotechar='"', quoting=csv.QUOTE_MINIMAL)
for x in f1:
temp = [x["user"]["lang"],x["user"]["statuses_count"]]
fileWriter.writerow(temp)
file1.close()