diff --git a/CSVConverter.py b/CSVConverter.py index b9051ab..6c09bf2 100644 --- a/CSVConverter.py +++ b/CSVConverter.py @@ -13,6 +13,8 @@ # Directory to read data files from. DATA_DIR = "./CobblemonData/" +# Name of the outputted spreadsheet. +CSV_NAME = "CobblemonData.csv" # Contains all the headers and where to get the values. HEADERS = { @@ -39,7 +41,7 @@ def main(): # Create CSV in write mode. - with open("CobblemonData.csv", mode = "w", encoding = "utf-8") as csv_file: + with open(CSV_NAME, mode = "w", encoding = "utf-8") as csv_file: csv_writer = csv.writer(csv_file, quotechar='"', quoting=csv.QUOTE_MINIMAL) # Create headers. csv_writer.writerow(HEADERS.keys()) @@ -79,6 +81,8 @@ def main(): # Write all the information into the row. csv_writer.writerow(getheader_values(temp_data)) + print(f"Done generating {CSV_NAME}.") + # Close file. p_file.close() @@ -143,12 +147,7 @@ def getheader_values(poke_data: CobblemonData) -> list: header_values.append(getattr(poke_data, value_location[0])()) # Dictionary has value. else: - try: - data_gotten = getattr(poke_data, value_location[0])[value_location[1]] - header_values.append(data_gotten) - except KeyError: - header_values.append("meow") - # print(e) + header_values.append(getattr(poke_data, value_location[0])[value_location[1]]) # Capitalize all the Pokemon names. header_values[1] = header_values[1].title() @@ -156,6 +155,5 @@ def getheader_values(poke_data: CobblemonData) -> list: return header_values - if __name__ == "__main__": main() diff --git a/CobblemonData.py b/CobblemonData.py index b8b813d..d213a72 100644 --- a/CobblemonData.py +++ b/CobblemonData.py @@ -241,8 +241,7 @@ def get_weight_multiplier(self) -> str: if self.spawns["weightMultiplier"] is not None: unclean_data = self.spawns["weightMultiplier"] # Clean up data. - clean_data = unclean_data.replace("{", "") - clean_data = clean_data.replace("}", "") + clean_data = unclean_data.replace("{", "").replace("}", "") clean_data = clean_data.replace("multiplier:", "") clean_data = clean_data.replace("condition:", "") clean_data = clean_data.strip() @@ -252,7 +251,7 @@ def get_weight_multiplier(self) -> str: # Format the data (multiplier IF [conditions]) formatted_data = f"x{splitted_data[0]} IF [{splitted_data[1].strip()}" for item in splitted_data[2:]: - formatted_data = formatted_data + ", " + item.strip() + formatted_data += ", " + item.strip() formatted_data = formatted_data + "]" return formatted_data