Last active
April 16, 2020 17:29
-
-
Save RoyalScribblz/ee5361837bb351bc6d02e7721341d515 to your computer and use it in GitHub Desktop.
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
| #Content is from a csv file which is in the format ID,buy-price,sell-price for items and just the name for a category | |
| import csv | |
| counter = 0 | |
| completed = "" | |
| categories = 0 | |
| items = 0 | |
| filename = input("Enter .csv filename: ") + ".csv" | |
| with open(filename) as csvfile: | |
| creader = csv.reader(csvfile) | |
| for row in creader: | |
| if len(row) == 1: | |
| completed += f"{row[0].capitalize()}:\n" | |
| categories += 1 | |
| counter = 0 | |
| else: | |
| mcid = row[0].upper() | |
| completed += (f" '{counter}':\n type: SHOP\n id: {mcid}\n buy-price: {float(row[1])}\n sell-price: {float(row[2])}\n") | |
| counter += 1 | |
| items += 1 | |
| output = open("shops.yml", "w") | |
| output.write(completed) | |
| output.close() | |
| print(f"[Done] {categories} categories created and {items} items added!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment