def save_load_correct(): table = Table("data_table4.dat") people_list = [["Amy", "23", "121"], ["Bridgette", "32", "144"], ["Dave", "26", "153"], ["Joe", "44", "176"]] try: table.set_attributes(["name", "age", "weight"]) table.append(people_list[0]) table.append(people_list[1]) table.append(people_list[2]) table.append(people_list[3]) table.save() except: return "0" table = Table("data_table4.dat") try: table.set_attributes(["name", "age", "weight"]) table.load() if table.sequential_search(FLAG_FIRST) != people_list[0]: return "0" if table.sequential_search(FLAG_NEXT) != people_list[1]: return "0" if table.sequential_search(FLAG_LAST) != people_list[3]: return "0" except: return "0" return "4"
def load_checks_format(): table = Table("data_table2.dat") try: table.set_attributes(["name", "age"]) table.append(["Joe", "19"]) table.save() except: return "0" table = Table("data_table2.dat") try: table.set_attributes(["name", "age", "weight"]) except: return "0" try: table.load() except: return "0.5" return "0"
def load_overwrites(): table = Table("data_table3.dat") try: table.set_attributes(["name", "age"]) table.append(["Joe", "19"]) table.save() except: return "0" table = Table("data_table3.dat") try: table.set_attributes(["name", "age"]) table.append(["Alice", "33"]) table.append(["Frank", "48"]) table.load() if table.get_size() == 1: return "0.5" except: return "0" return "0"