def parse(self, file):
for i, line in enumerate(file, start=1):
try:
j = json.loads(line)
j["meta"] = json.dumps(j.get("meta", {}))
yield j
except json.decoder.JSONDecodeError:
raise FileParseException(line_num=i, line=line)
After Change
file = io.TextIOWrapper(file, encoding="utf-8")
while True:
batch = list(itertools.islice(file, IMPORT_BATCH_SIZE))
if not batch:
raise StopIteration
yield [{"text": line.strip()} for line in batch]
class CSVParser(FileParser):