Created
July 11, 2018 13:55
-
-
Save cyaoeu/4e19b6264194e8286812add8ab38a5a0 to your computer and use it in GitHub Desktop.
Extract JSON from txt files containing other stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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