I have some code that creates a CSV file. The order of the rows it writes to the file can vary. I am writing a test to make sure the CSV file is what I expect. All I need to do is check that all rows are present and all fields equal. I have the code below, but am not sure how to get it to work so it doesn't care about the order of the rows. How can I make sure two CSV files contain the same rows, but the order of the rows doesn't matter?
def assertRowsEqual(self, first, second)
error_count = 0
first_f = open(first)
csv1 = csv.reader(first_f, delimiter=',', quotechar='"',
quoting=csv.QUOTE_ALL)
second_f = open(second)
csv2 = csv.reader(second_f, delimiter=',', quotechar='"',
quoting=csv.QUOTE_ALL)
for row1 in csv1:
row2 = csv2.next()
if row1 != row2:
self.fail("NOT THE SAME\n")