From 0798e1ccc53feda54eb870d1c1a111a94d48039a Mon Sep 17 00:00:00 2001 From: Arno Candel Date: Sat, 23 May 2015 02:56:25 -0700 Subject: [PATCH] Update SVMLight script to also check file sanity. --- .../{svmlight_sortcols.py => svmlight_check_and_sort.py} | 8 ++++++++ 1 file changed, 8 insertions(+) rename scripts/{svmlight_sortcols.py => svmlight_check_and_sort.py} (75%) diff --git a/scripts/svmlight_sortcols.py b/scripts/svmlight_check_and_sort.py similarity index 75% rename from scripts/svmlight_sortcols.py rename to scripts/svmlight_check_and_sort.py index f91092bdeef8..9ab42fe08415 100644 --- a/scripts/svmlight_sortcols.py +++ b/scripts/svmlight_check_and_sort.py @@ -26,6 +26,14 @@ dsorted = sorted(d.iteritems(), key=itemgetter(0), reverse=False) with open(output, "a") as g: g.write(target + ' ') + prev_i=-1 for (i,j) in dsorted: + if(i == 0): + print("Column index must be >= 1: " + dsorted) + exit(1) + if(i == prev_i): + print("Repeats found: " + dsorted) + exit(1) + prev_i = i g.write(str(i)+':'+str(j)+' ') g.write('\n')