-------------------------------------------------- glyph_diff.py -------------------------------------------------- # # glyph_diff import os import sys TRUE=1 FALSE=0 exclude = FALSE if (len(sys.argv) > 1): exclude = TRUE ok_type = int(sys.argv[1]) # print "ok_type = %d" % (ok_type) ignore_col = FALSE if (len(sys.argv) > 2): ignore_col = TRUE nok_col = int(sys.argv[2]) # print "nok_col = %d" % (nok_col) csv_1 = open("file1.txt", "r").readlines() csv_2 = open("file2.txt", "r").readlines() csvLineList_1 = csv_1[0].split(",") csvLineList_2 = csv_2[0].split(",") num_cols = len(csvLineList_1) for lineCount in range( 1, len( csv_1 ) ): csvLineList_1 = csv_1[lineCount].split(",") csvLineList_2 = csv_2[lineCount].split(",") good_line = TRUE if (exclude and float(csvLineList_1[1]) != ok_type): good_line = FALSE if (good_line): for colCount in range(num_cols): if (not ignore_col or colCount != nok_col - 1): if csvLineList_1[colCount] != csvLineList_2[colCount]: print "%d,%d:%f,%f" % \ (lineCount, colCount + 1, float(csvLineList_1[colCount]), \ float(csvLineList_2[colCount])) -------------------------------------------------- Run -------------------------------------------------- # python ./glyph_diff.py 5 4 > glyph_diff.txt cat glyph_diff.txt -------------------------------------------------- file1.txt -------------------------------------------------- a,b,c,d 1,2,3,4 5,6,7,8 9,10,11,12 -------------------------------------------------- file2.txt -------------------------------------------------- a,b,c,d 0,2,3,4 5,6,7,8 9,10,11,12 --------------------------------------------------