Reference this blog
https://www.cnblogs.com/saryli/p/8576632.html
Except where:
1 with open(file_path, 'r', encoding='utf-8') as f: 2 try: 3 while True: 4 line = f.readline() 5 if line: 6 r = json.loads(line) 7 # print(r) 8 else: 9 break 10 except: 11 f.close()
This is not particularly feel properly (if line), so I put it to read as follows:
1 with open(file_path, 'r', encoding='utf-8') as f: 2 try: 3 lines = f.readlines() 4 for line in lines: 5 r = json.loads(line) 6 # print(r) 7 8 except: 9 f.close()