import json, sys sys.stdout.reconfigure(encoding='utf-8') with open('scratch/wide_criteria_my_scope.json', 'r', encoding='utf-8') as f: data = json.load(f) # Group by file by_file = {} for d in data: f = d['file'] if f not in by_file: by_file[f] = [] by_file[f].append(d) for fname, items in by_file.items(): print(f"\n=======================================================") print(f"File: {fname} (Total: {len(items)})") print(f"=======================================================") for item in items[:6]: # show first 6 print(f"L{item['line']}: {item['reasons']}") print(f" RAW: {item['raw_line']}")