added docstring

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40394
This commit is contained in:
samus_ 2008-11-22 19:20:53 +00:00
parent 1458686cbf
commit d4040d73d9
1 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,18 @@ def xmliter(obj, nodename):
yield XmlXPathSelector(text=nodetext).x('/' + nodename)[0]
def csviter(obj, delimiter=None, headers=None):
""" Returns an iterator of dictionaries from the given csv object
obj can be:
- a Response object
- a unicode string
- a string encoded as utf-8
delimiter is the character used to separate field on the given obj.
headers is an iterable that when provided offers the keys
for the returned dictionaries, if not the first row is used.
"""
def _getrow(csv_r):
return [field.decode() for field in csv_r.next()]