Repository navigation
io.ascii: improve guessing when format is specified - #3418
Conversation
|
@astrofrog - the The knowledge that a reader class doesn't have any additional guessable parameters is currently coded in the guess routine. We could refactor a bit so that the reader class knows how to guess itself and in that way disable guessing at the |
|
For some formats there is also a fast and a slow reader. Guessing will try the fast reader first, if it exists. If there is really only one reader and that trader has no options, then the reading still goes through the guess function, but that function should simply call the reader in question. I don't think that we gain any performance by implementing logic to decide if guessing is needed instead of iterating over a list of one reader. |
There was a problem hiding this comment.
This line eliminates duplicate guesses. It turns out in some cases the basic format could have 3 or 4 repeats.
There was a problem hiding this comment.
I wonder how thee repeats happen in the first case? I remember that I looked into the guessing a while ago when I changed the order in which formats are tried in guessing, and I definitely remember that this is no easy logic. I'm not oppsed to fixing it in ths way if that is the best solution, I just wonder if this points to some deeper problem or if you know why basic is in there multiple times.
|
@astrofrog @hamogu - code attached. |
At the beginning of _guess there was a code block that tries to read the `table` input as a file or readable file object. This was moved up one level from _guess so that if there is just one guess_kwargs then the same already-read `table` is used for the non-guess reading path.
df6e08d to
6c3b35c
Compare
There was a problem hiding this comment.
If there is only one format, why should we return None? It is possible that an imcomplete set of options (delimiter etc.) is passed into guess and guess substituted default values for other options. In that case, _guess did something and I would expect it to return something.
There was a problem hiding this comment.
I see why you did it and I think itś a clever way to do it, but its logic might need a comment or two to explain.
|
Look good to me now. I suspected that your code was right from the
beginning, but now I an other people (and you when you come back three
weeks from now) can also understand why it works the why it works.
|
io.ascii: improve guessing when format is specified
When trying to read a large table yesterday I noticed that if I did:
io.asciiwas still trying to guess the format and I had to useto prevent the guessing. Should specifying the format not disable guessing?