Skip to content

Commit

Permalink
Updated code and displays finish message.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasQTruong committed Oct 25, 2023
1 parent e6159f3 commit 6feee55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 6 additions & 8 deletions CSVConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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())
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -143,19 +147,13 @@ 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()

return header_values



if __name__ == "__main__":
main()
5 changes: 2 additions & 3 deletions CobblemonData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

0 comments on commit 6feee55

Please sign in to comment.