PyNE work done for Rachel Slaybaugh at UC Berkeley. http://pyne.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
850 B

  1. import csv
  2. import itertools
  3. var = "extra"
  4. file1 = open(var + ".csv", "rb")
  5. file2 = open("/Users/clayshieh/Documents/MATLAB/" + var + "_m.txt", "rb")
  6. r1 = csv.reader(file1)
  7. r2 = csv.reader(file2)
  8. row_count1 = sum(1 for row in r1)
  9. row_count2 = sum(1 for row in r2)
  10. if row_count1 != row_count2:
  11. print "Actual has " + str(row_count1) + " rows Expected has " + str(row_count2) + "rows."
  12. file1.close()
  13. file2.close()
  14. file1 = open(var + ".csv", "rb")
  15. file2 = open("/Users/clayshieh/Documents/MATLAB/" + var + "_m.txt", "rb")
  16. reader1 = csv.reader(file1)
  17. reader2 = csv.reader(file2)
  18. row = 0
  19. for lhs, rhs in zip(reader1, reader2):
  20. column = 0
  21. for lh, rh in zip(lhs, rhs):
  22. if abs(float(lh) - float(rh)) >= 1e-10:
  23. print "Actual: " + str(lh) + " Expected: " + str(rh) + " at: (" + str(row) + "," + str(column) + ")"
  24. column += 1
  25. row += 1
  26. print row