summaryrefslogtreecommitdiff
path: root/tablib/core.py
diff options
context:
space:
mode:
authorJosh Ourisman <josh@joshourisman.com>2010-10-01 16:17:04 -0400
committerJosh Ourisman <josh@joshourisman.com>2010-10-01 16:17:04 -0400
commit149bafa97b3c93b5116090d2834f0c19e6face95 (patch)
tree92093fdfb234913153fed618ca9947ff8423023b /tablib/core.py
parent9f7fec23793b25c7aeffcee4186d6009dc816cca (diff)
downloadtablib-149bafa97b3c93b5116090d2834f0c19e6face95.tar.gz
added ability to append new column passing a callable as the value that will be applied to every row; w/ test
Diffstat (limited to 'tablib/core.py')
-rw-r--r--tablib/core.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tablib/core.py b/tablib/core.py
index 8f74975..dfb8027 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -177,6 +177,15 @@ class Dataset(object):
self._validate(row)
self._data.append(tuple(row))
elif col is not None:
+ col = list(col)
+ if self.headers:
+ header = [col.pop(0)]
+ else:
+ header = []
+ if len(col) == 1 and callable(col[0]):
+ col = map(col[0], self._data)
+ col = tuple(header + col)
+
self._validate(col=col)
if self.headers: