def main(): #pprinter for debugging and visdualizing data usage. pp = pprint.PrettyPrinter(indent=2) #List all files in the cwd. os.listdir('.') new_parser = pa.DataParser() #Empty dict that will contain subdicts representing each row. data_set = new_parser.parse_csv('volunteer_sample_2.csv') pp.pprint(data_set)
def check_random_row(self, file_name): """ Check if all the values in a random row in the csv file are equivalent to it's corresponding entry in the date_set dict. file_name - Name of the file to be checked. """ data_set = pa.DataParser().parse_csv(file_name) test_tup = self.get_CSV_Reader(file_name) #Pick a random row and iterate to it. row_num = random.randrange(2, 200) row = None for x in range(row_num): row = next(test_tup[1]) #Check that all of the variables in the csv row are equivalent to those #in that row's entry in the data_set dictionary. entry = data_set[row_num] for col, key in zip(row, entry.keys()): self.assertEqual(col, entry[key]) test_tup[0].close()