summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
authorKevin Cherepski <kcherepski@visual-a.com>2015-02-04 11:53:14 -0500
committerKevin Cherepski <kcherepski@visual-a.com>2015-02-04 11:53:14 -0500
commitdca7bc9a7d637cfa6f0f00eaebe8bd0cb4e2d7cd (patch)
treec8b69d44e526bc5068d7ef2bb651a01d35ae6166 /tablib
parent2fbda0f43ddf1d2f3a2fe88b9320b8d04f449d4d (diff)
downloadtablib-dca7bc9a7d637cfa6f0f00eaebe8bd0cb4e2d7cd.tar.gz
Adding ability to unique all rows in a dataset.
Diffstat (limited to 'tablib')
-rw-r--r--tablib/core.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tablib/core.py b/tablib/core.py
index f8e2df7..069646c 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -934,6 +934,13 @@ class Dataset(object):
return _dset
+ def unique(self):
+ """Removes all duplicate rows from the :class:`Dataset` object
+ while maintaining the original order."""
+ seen = set()
+ self._data[:] = [row for row in self._data if not (tuple(row) in seen or seen.add(tuple(row)))]
+
+
def wipe(self):
"""Removes all content and headers from the :class:`Dataset` object."""
self._data = list()