-
Notifications
You must be signed in to change notification settings - Fork 42
Conversation
@zhenyab |
@@ -23,7 +20,9 @@ def detect_scheme(source): | |||
For example `http` from `http://example.com/table.csv` | |||
|
|||
""" | |||
if hasattr(source, 'read'): | |||
if isinstance(source, list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need something smarter to work not only with lists but any iterables.
May be we should use NativeLoader
for any non string sources (closing else
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import types
# stuff
if isinstance(source, (list, tuple, set, types.GeneratorType)):
pass
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll test it tomorrow but it looks very good.
@@ -53,7 +53,7 @@ def __emit_items(self): | |||
prefix = '%s.item' % self.__path | |||
items = ijson.items(self.__chars, prefix) | |||
for item in items: | |||
if isinstance(item, list): | |||
if isinstance(item, (tuple, list)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roll why not set or generators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pwalsh
Sorry I haven't answered it yet but I've checked types.GeneratorType
it doesn't work for e.g. iter([1,2,3])
. So I've decided to pass to NativeLoader/Parser
all data types except file-like and strings - it's in detect_scheme/detect_format
.
But check here is about rows:
[
('a','b','c'), # tuple
(1,2,3), # tuple
[1,2,3], # list
]
So almost there is no chance to have here generators/iterators and set is not ordered. It looks tuple-list could be enough. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right. good. thanks
It fixes #35