mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Generic method import_book (similar to import_set) to import data into Databook model.
This commit is contained in:
@@ -1008,6 +1008,19 @@ def import_set(stream):
|
||||
return None
|
||||
|
||||
|
||||
def import_book(stream):
|
||||
"""Return dataset of given stream."""
|
||||
(format, stream) = detect(stream)
|
||||
|
||||
try:
|
||||
databook = Databook()
|
||||
format.import_book(databook, stream)
|
||||
return databook
|
||||
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
|
||||
class InvalidDatasetType(Exception):
|
||||
"Only Datasets can be added to a DataBook"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user