import csv import json from glob import glob import pandas as pd df = pd.concat([pd.read_csv(i, quoting=csv.QUOTE_NONE, encoding='utf-8', sep='\t', header=None, on_bad_lines='skip') for i in glob('seamless.dataset.metadata.public.jpn.batch_*.tsv')]) line_no = [i.split(" ")[3] for i in df[0]] text = df[1].values.tolist() with open("text.enA-jpn.json", "w") as f: json.dump({l: t for l, t in zip(line_no, text)}, f)