Skip to content

Instantly share code, notes, and snippets.

@cyaoeu
Created July 11, 2018 13:55
Show Gist options
  • Save cyaoeu/4e19b6264194e8286812add8ab38a5a0 to your computer and use it in GitHub Desktop.
Save cyaoeu/4e19b6264194e8286812add8ab38a5a0 to your computer and use it in GitHub Desktop.
Extract JSON from txt files containing other stuff
import shutil
import glob
path = "C:\\beatsaber\\OST\\"
filenames = glob.glob(path + "*.txt")
for filename in filenames:
with open(filename, 'r') as txtfile:
data=txtfile.read().replace('\n', '')
splitstring = data.split('_jsonData = "')[1].rsplit('"', 1)[0]
print(splitstring)
with open(filename.rsplit(".", 1)[0] + ".json", 'w') as jsonfile:
jsonfile.write(splitstring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment