Created
April 22, 2020 12:47
-
-
Save RoyalScribblz/47df811920a1b0cedb9f141ecbd15ae5 to your computer and use it in GitHub Desktop.
Convert GuiShop shops.yml to Essentials worth.yml
This file contains hidden or 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 re | |
| import csv | |
| items = [] | |
| success = 0 | |
| with open("items.csv", "r") as itemscsv: | |
| for line in itemscsv: | |
| items.append(re.sub("\n", "", line)) | |
| worthyml = "worth:\n" | |
| with open("shops.yml", "r") as shopsyml: | |
| for line in shopsyml: | |
| if line.startswith(" id:"): | |
| item = re.sub("_", "", (" ".join(line.split(" id: ", 1)[1].split()).lower())) | |
| elif line.startswith(" sell-price:"): | |
| sellval = float(line.split(" sell-price: ", 1)[1]) | |
| if item in items: | |
| worthyml += f" {item}: {sellval}\n" | |
| success += 1 | |
| else: | |
| print(f"{item} was unable to be added!") | |
| worth = open("worth.yml", "w") | |
| worth.write(worthyml) | |
| worth.close() | |
| print(f"\n{success} items added to worth.yml successfully!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment