#! /usr/bin/python3 import json input = open("albums.dat", "r") lines = input.read().splitlines() with open("albums.json", "w") as out: l = [] for line in lines: split = line.split('\\') link = split[0] name = split[1] artist = split[2] l.append({"name": name, "artist": artist, "link": link}) j = json.dumps(l, indent=2) out.write(j)