Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import csv
- import os
- from pathlib import Path
- f = open('sample/reports 1/1report.json')
- data = json.load(f)
- outputs = []
- for i in data['behavior']['apistats']:
- temp_value = ''
- for index, j in enumerate(data['behavior']['apistats'][i]):
- if index==0:
- temp_value += j
- else:
- temp_value += ' '+j
- outputs.append([temp_value])
- if not os.path.isdir('outputs/'):
- os.mkdir('outputs')
- if not os.path.isdir('outputs/reports 1/'):
- Path("outputs/reports 1/").mkdir(parents=True, exist_ok=True)
- filename = "outputs/reports 1/1report.csv"
- with open(filename, 'w', newline='') as csvfile:
- csvwriter = csv.writer(csvfile)
- csvwriter.writerows(outputs)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement