Skip to content

Instantly share code, notes, and snippets.

@nijave
Last active January 8, 2020 01:03
Show Gist options
  • Save nijave/e75eaa0b6c77566d09292a95b153e517 to your computer and use it in GitHub Desktop.
Save nijave/e75eaa0b6c77566d09292a95b153e517 to your computer and use it in GitHub Desktop.
import json
import re
with open("AARON1.DAT", "r") as f:
workoutfile = f.read().strip()
workouts_json = "[" + workoutfile.replace(" }\n}\n{", "},\n{").replace("}\n{", "},\n{").strip()[0:-1] + "]"
try:
workouts = json.loads(workouts_json)
except json.decoder.JSONDecodeError as e:
print("Failed to parse line %i" % e.lineno)
print("\n".join(workouts_json.splitlines()[e.lineno-1:e.lineno+2]).encode("unicode_escape").decode("ascii"))
from pprint import pprint
user_data = workouts.pop(0)
pprint(workouts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment