|
import json |
|
import csv |
|
|
|
def convert_jsonl_to_csv(jsonl_file, csv_file): |
|
with open(jsonl_file, 'r',encoding='utf-8') as file: |
|
json_data = [json.loads(line) for line in file] |
|
|
|
if len(json_data) > 0: |
|
fields = list(json_data[0].keys()) |
|
|
|
with open(csv_file, 'w', newline='',encoding='utf-8') as file: |
|
writer = csv.DictWriter(file, fieldnames=fields) |
|
writer.writeheader() |
|
|
|
for data in json_data: |
|
writer.writerow(data) |
|
|
|
|
|
jsonl_file = 'Read_Comperhension50k.jsonl' |
|
csv_file = 'Read_Comperhension50k.csv' |
|
convert_jsonl_to_csv(jsonl_file, csv_file) |