summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
Diffstat (limited to 'tablib')
-rw-r--r--tablib/core.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/tablib/core.py b/tablib/core.py
index 1214f99..e7b622c 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -22,7 +22,7 @@ class Dataset(object):
self.__headers = None
# ('title', index) tuples
- self._seperators = []
+ self._separators = []
try:
self.headers = kwargs['headers']
@@ -36,6 +36,7 @@ class Dataset(object):
self._register_formats()
+
def __len__(self):
return self.height
@@ -197,24 +198,26 @@ class Dataset(object):
self._data = [tuple([row]) for row in col]
- def insert_seperator(self, index, text='-'):
- """Adds a seperator to Dataset at given index."""
+ def insert_separator(self, index, text='-'):
+ """Adds a separator to Dataset at given index."""
- if self.height >= index:
- sep = (index, text)
- self._seperators.append(sep)
- else:
- raise InvalidDimensions
+ sep = (index, text)
+ self._separators.append(sep)
- def append_seperator(self, text='-'):
- """Adds a seperator to Dataset."""
-
- index = self.height if self.headers else (self.height - 1)
- self.insert_seperator(index, text)
+ def append_separator(self, text='-'):
+ """Adds a separator to Dataset."""
+
+ # change offsets if headers are or aren't defined
+ if not self.headers:
+ index = self.height if self.height else 0
+ else:
+ index = (self.height + 1) if self.height else 1
+
+ self.insert_separator(index, text)
- def insert(self, i, row=None, col=None):
+ def insert(self, i, row=None):
"""Inserts a row at given position in Dataset"""
if row:
self._validate(row)