summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2009-09-29 15:51:56 +0200
committerEmile Anclin <emile.anclin@logilab.fr>2009-09-29 15:51:56 +0200
commita0873bb46acdb7a75d10fac6b7b5cfb0abc31fe9 (patch)
treef6dc5f7850c3314199f8c453ae40644604165db8
parent92a6f980384f58f0fdab73360ad5287bd9d3cd04 (diff)
downloadlogilab-common-a0873bb46acdb7a75d10fac6b7b5cfb0abc31fe9.tar.gz
[B, table] add a missing get_column method
-rw-r--r--table.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/table.py b/table.py
index df1e23f..865087f 100644
--- a/table.py
+++ b/table.py
@@ -383,12 +383,17 @@ class Table(object):
raise KeyError("Column (%s) not found in table" % (col_id))
return self.get_column(col_index, distinct)
-
def get_columns(self):
"""Returns all the columns in the table
"""
return [self[:,index] for index in range(len(self.col_names))]
+ def get_column(self, col_index, distinct=False):
+ """get a column by index"""
+ col = [row[col_index] for row in self.data]
+ if distinct:
+ col = list(set(col))
+ return col
def apply_stylesheet(self, stylesheet):
"""Applies the stylesheet to this table