def main(): get_prices_from_csv("Virtual Boy") get_prices_from_csv("Gamecube") get_prices_from_csv("Wii") get_prices_from_csv("Wii U") get_prices_from_csv("NES") get_prices_from_csv("Super Nintendo") get_prices_from_csv("Nintendo 64") get_prices_from_csv("Nintendo Switch") get_prices_from_csv("GameBoy") get_prices_from_csv("GameBoy Color") get_prices_from_csv("GameBoy Advance") get_prices_from_csv("Nintendo DS") get_prices_from_csv("Nintendo 3DS")
def main(): get_prices_from_csv("Amiibo") get_prices_from_csv("3DO") get_prices_from_csv("TurboGrafx-16") get_prices_from_csv("Nintendo Power") get_prices_from_csv("Neo Geo")
def main(): get_prices_from_csv("Sega Master System") get_prices_from_csv("Sega Genesis") get_prices_from_csv("Sega CD") get_prices_from_csv("Sega 32X") get_prices_from_csv("Sega Saturn") get_prices_from_csv("Sega Dreamcast") get_prices_from_csv("Sega Game Gear")
def main(): get_prices_from_csv("Playstation") get_prices_from_csv("Playstation 2") get_prices_from_csv("Playstation 3") get_prices_from_csv("Playstation 4") get_prices_from_csv("Playstation Vita") get_prices_from_csv("PSP")
def get_any_csv(): date = datetime.datetime.today() console = input("Which console do you want to search for? ") console_dash = console.replace(" ", "-").lower() compare_answer = input("Do you want to also compare the prices? ").lower() # This opens the file we are comparing against and sets to the variables we will use much later. if compare_answer == "yes": compare_days_str = input("And how many days ago do you want to compare against? ") compare_days = int(compare_days_str) try: loose_price_list, cib_price_list, new_price_list, game_id_list, name_list = compare2(compare_days, console_dash) except IOError: print("That data does not exist, try another date!") exit() # This is the magic that gets us our current data file get_prices_from_csv(console) # Set all the values before we get into the for loop counter = 0 difference_gain_loose = 0 difference_gain_cib = 0 difference_gain_new = 0 # Open the data file for the Console try: prices_file = open('prices/' + console_dash + '/prices_' + str(date.strftime('%m-%d-%Y')) + '.txt', 'r') except IOError: print("That file does not exist!") exit() contents = prices_file.readlines() print() active_game_id_list = [] lost_and_found_game_ids = [] for x in contents: if prices_file.mode == 'r': # Read the data file that we just created splitter = x.split("//") game_id = splitter[0].strip() name = splitter[1].strip() active_game_id_list.append(game_id) loose_price = splitter[2].replace(" ", "") cib_price = splitter[3].replace(" ", "") new_price = splitter[4].replace(" ", "") # Check to see if we're missing data, in which case we skip. Otherwise it looks wonky! if loose_price == "" or cib_price == "" or new_price == "": print("The item '" + name + "' is missing some data!") print() counter += 1 continue print("The item '" + name + "' is currently running " + str(loose_price) + " loose, " + str(cib_price) + " complete, and " + str(new_price) + " brand new") # Run the compare function if the user wants to if compare_answer == "yes": try: if game_id_list[counter].strip() != game_id: if game_id in game_id_list[counter:-1]: # This fixes the list IF the item was reordered in the future part of the list print("Looks like this ID was reordered, oops!") print("But here is our best attempt to getting the prices anyways") print() compare_next(loose_price, loose_price_list, cib_price, cib_price_list, new_price, new_price_list, counter + 1) lost_and_found_game_ids.append(game_id_list[counter]) counter += 2 continue new_active_game_id_list = active_game_id_list if game_id_list[counter].strip() in new_active_game_id_list: # This will fix the list and also report the misplaced item. print("That ID already was used, looks like it got renamed!") print("But here is our best attempt to getting the prices anyways") print() compare_next(loose_price, loose_price_list, cib_price, cib_price_list, new_price, new_price_list, counter+1) counter += 2 continue if game_id in lost_and_found_game_ids: # This is where I do something to show those results now... How do I find them? print("I need to add a feature here that parses " "the list and let's see find the values by game ID.") # If not on a list and not in the future, well, who knows what went wrong print("Oops, looks like the game ID doesn't match!") print() continue except IndexError: print("Oops you've hit the end of the file, RIP!") exit() # Can't report if we are missing data so we need to stop the for loop here if loose_price_list[counter] == "" or cib_price_list[counter] == "" or new_price_list[counter] == "": print("The item '" + name + "' is missing some compare data!") print() counter += 1 continue # I can probably get the below all into a single method, but that would require a lot of passing # of variables. I think for now I'll leave it as is, even though it's bulky. difference_loose = float(loose_price.replace("$", "")) - float(loose_price_list[counter]) difference_cib = float(cib_price.replace("$", "")) - float(cib_price_list[counter]) difference_new = float(new_price.replace("$", "")) - float(new_price_list[counter]) old_price_loose = loose_price_list[counter] old_price_cib = cib_price_list[counter] old_price_new = new_price_list[counter] percent_change_loose = get_change(float(loose_price.replace("$", "")), float(old_price_loose)) percent_change_cib = get_change(float(cib_price.replace("$", "")), float(old_price_cib)) percent_change_new = get_change(float(new_price.replace("$", "")), float(old_price_new)) if percent_change_loose > difference_gain_loose: difference_gain_loose = percent_change_loose difference_gain_loose_value = loose_price difference_name_loose = name if percent_change_cib > difference_gain_cib: difference_gain_cib = percent_change_cib difference_gain_cib_value = cib_price difference_name_cib = name if percent_change_new > difference_gain_new: difference_gain_new = percent_change_new difference_gain_new_value = new_price difference_name_new = name print("The old prices were: ") if difference_loose > 0: print(" Loose: $" + old_price_loose + " a total difference of $" + str(round(difference_loose, 2)) + " and a % increase of " + str(round(percent_change_loose, 2)) + "%!") elif difference_loose == 0: print(" Loose: $" + old_price_loose + " with no difference changes in total or percentage") elif difference_loose < 0: print(" Loose: $" + old_price_loose + " a total difference of $" + str(round(difference_loose, 2)) + " and a % decrease of " + str(round(percent_change_loose, 2)) + "%!") if difference_cib > 0: print(" Complete: $" + old_price_cib + " a total difference of $" + str(round(difference_cib, 2)) + " and a % increase of " + str(round(percent_change_cib, 2)) + "%!") elif difference_cib == 0: print(" Complete: $" + old_price_cib + " with no difference changes in total or percentage") elif difference_cib < 0: print(" Complete: $" + old_price_cib + " a total difference of $" + str(round(difference_cib, 2)) + " and a % decrease of " + str(round(percent_change_cib, 2)) + "%!") if difference_new > 0: print(" New: $" + old_price_new + " a total difference of $" + str(round(difference_new, 2)) + " and a % increase of " + str(round(percent_change_new, 2)) + "%!") elif difference_new == 0: print(" New: $" + old_price_new + " with no difference changes in total or percentage") elif difference_new < 0: print(" New: $" + old_price_new + " a total difference of $" + str(round(difference_new, 2)) + " and a % decrease of " + str(round(percent_change_new, 2)) + "%!") print() else: print() counter += 1 if compare_answer == "yes": print_gainers(difference_gain_loose, difference_gain_cib, difference_gain_new, compare_days_str, difference_name_loose, difference_gain_loose_value, difference_name_cib, difference_gain_cib_value, difference_name_new, difference_gain_new_value)
def main(): get_prices_from_csv("Xbox") get_prices_from_csv("Xbox 360") get_prices_from_csv("Xbox One")
def main(): # Nintendo get_prices_from_csv("Virtual Boy") get_prices_from_csv("Gamecube") get_prices_from_csv("Wii") get_prices_from_csv("Wii U") get_prices_from_csv("NES") get_prices_from_csv("Super Nintendo") get_prices_from_csv("Nintendo 64") get_prices_from_csv("Nintendo Switch") get_prices_from_csv("GameBoy") get_prices_from_csv("GameBoy Color") get_prices_from_csv("GameBoy Advance") get_prices_from_csv("Nintendo DS") get_prices_from_csv("Nintendo 3DS") # Sega get_prices_from_csv("Sega Master System") get_prices_from_csv("Sega Genesis") get_prices_from_csv("Sega CD") get_prices_from_csv("Sega 32X") get_prices_from_csv("Sega Saturn") get_prices_from_csv("Sega Dreamcast") get_prices_from_csv("Sega Game Gear") # Sony get_prices_from_csv("Playstation") get_prices_from_csv("Playstation 2") get_prices_from_csv("Playstation 3") get_prices_from_csv("Playstation 4") get_prices_from_csv("Playstation Vita") get_prices_from_csv("PSP") # Microsoft get_prices_from_csv("Xbox") get_prices_from_csv("Xbox 360") get_prices_from_csv("Xbox One") # Other get_prices_from_csv("Amiibo") get_prices_from_csv("3DO") get_prices_from_csv("TurboGrafx-16") get_prices_from_csv("Nintendo Power") get_prices_from_csv("Neo Geo")