Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yaml
- from os import listdir
- from os.path import join, basename
- files = listdir("input/")
- total_size = str(len(files))
- current = 0
- for unsafe in files:
- with open(join("input/", unsafe), 'r') as unsafe:
- with open(join("output/", basename(unsafe.name).split(".")[0] + ".clean.yml"), 'w') as out_file:
- try:
- unsafe_data = yaml.load(unsafe)
- safe_data = {}
- safe_data['homes'] = unsafe_data.get('homes', [])
- safe_data['money'] = unsafe_data.get('money', 0)
- safe_data['nickname'] = unsafe_data.get('nickname', "")
- yaml.dump(safe_data, out_file, default_flow_style=False)
- current += 1
- print("Processed " + str(current) + " of " + total_size)
- except yaml.YAMLError as ex:
- print(ex)
Add Comment
Please, Sign In to add comment