diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2009-09-29 15:51:56 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2009-09-29 15:51:56 +0200 |
commit | a0873bb46acdb7a75d10fac6b7b5cfb0abc31fe9 (patch) | |
tree | f6dc5f7850c3314199f8c453ae40644604165db8 | |
parent | 92a6f980384f58f0fdab73360ad5287bd9d3cd04 (diff) | |
download | logilab-common-a0873bb46acdb7a75d10fac6b7b5cfb0abc31fe9.tar.gz |
[B, table] add a missing get_column method
-rw-r--r-- | table.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 |