def file_changer_donation(Index_to_change,Row_index_to_change,Donation_file_path): lines = file_handler.read_file_content(Donation_file_path) try: if int(Index_to_change) <= 10 and int(Index_to_change) >= 1: index = int(Index_to_change) - 1 line = int(Row_index_to_change) else: return False except: return False print("Old line: {}".format(lines[line])) change = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[index],'') split_line = lines[line].split(",") split_line[index] = change new_line = ",".join(split_line) lines[Row_index_to_change] = new_line file_handler.rewrite_file_with_data(Donation_file_path,lines) return True
def file_changer_donor(Index_to_change,Row_index_to_change,Donor_file_path): lines = file_handler.read_file_content(Donor_file_path) try: if int(Index_to_change) <= 12 and int(Index_to_change) >= 1: index = int(Index_to_change) - 1 line = int(Row_index_to_change) else: return False except: return False print("Old line: {}".format(lines[line])) change = DonorInput.get_donor_data(DonorInput.DONOR_HEADER[index],'') if index == 6: if not file_handler.check_if_id_not_in_file(Donor_file_path,change): input("Id already in file.") return False split_line = lines[line].split(",") split_line[index] = change new_line = ",".join(split_line) lines[Row_index_to_change] = new_line file_handler.rewrite_file_with_data(Donor_file_path,lines) return True