Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
import json
infile = 'output_data.json'
outfile = 'output_readable.txt'
with open(infile, 'r', encoding='utf-8') as f:
data = json.load(f)
def printable(s):
return ''.join(ch for ch in s if 32 <= ord(ch) <= 126)
with open(outfile, 'w', encoding='utf-8') as f:
for idx, rec in enumerate(data, start=1):
f.write(f'Record {idx}:\n')
for k, v in rec.items():
k2 = printable(k)
v2 = printable(v)
f.write(f' Key: {k2 or ""}\n')
f.write(f' Value: {v2 or ""}\n')
f.write('\n')
print('Wrote', outfile)