From 8ef579f7148834f123010ee4e3a02fb2b9e5fd08 Mon Sep 17 00:00:00 2001 From: Kanwei Li Date: Tue, 4 Oct 2011 23:11:23 -0400 Subject: [PATCH] Grouping tool: make error clearer when a line doesn't have entry on grouped column --- tools/stats/grouping.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/stats/grouping.py b/tools/stats/grouping.py index 90f07a6093f..084d5e253b3 100644 --- a/tools/stats/grouping.py +++ b/tools/stats/grouping.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # Guruprasad Ananda -# Refactored 2011, Kanwei Li -# Refactored to use numpy instead of rpy +# Refactored 2011 to use numpy instead of rpy, Kanwei Li """ This tool provides the SQL "group by" functionality. """ @@ -83,7 +82,11 @@ def main(): fout = open(sys.argv[1], "w") def is_new_item(line): - item = line.strip().split("\t")[group_col] + try: + item = line.strip().split("\t")[group_col] + except IndexError: + stop_err( "The following line didn't have %s columns: %s" % (group_col+1, line) ) + if ignorecase == 1: return item.lower() return item