In [1]:
import ijson
import csv
In [2]:
#Parse json file
f1 = open("../data/transactions-500001-1000000.json")
d1 = []
for item in ijson.items(f1, "item"):
d1.append(item)
f = csv.writer(open("../data/transactions-500001-1000000.csv", "wb+"))
# Write CSV Header, If you dont need that, remove this line
f.writerow(["blockHash","blockNumber","from","gas","gasPrice","hash","input","nonce","timestamp","to","transactionIndex","value"])
for t in d1:
f.writerow([t["blockHash"],
t["blockNumber"],
t["from"],
t["gas"],
t["gasPrice"],
t["hash"],
t["input"],
t["nonce"],
t["timestamp"],
t["to"],
t["transactionIndex"],
t["value"]
])
In [ ]: