Skip to content

bug in io.ascii  #3319

Closed
Closed

Description

@aphearin

I am finding that in certain cases, io.ascii struggles to correctly ignore comment lines, and also the start of the data rows. Here is some particularly simple data that illustrates the problem:

# some header info
#F header info beginning with 'F'
1 2 3
4 5 6
7 8 9

If I run ascii.read(fname), I get
AttributeError: 'NoneType' object has no attribute 'group'

The workaround seems to be to set guess=False. Based on an email chain with @eteq the problem seems to be that the DAOPHOT reader specifically looks for the "#F..." pattern, and for some reason even though this is not a DAOPHOT output file, the reader fails when it tries to actually interpret that line. Erik told me to call the attention of @taldcroft to this issue.

My workaround for the time being is s imply to set guess=False:
ascii.read(fname, guess=False).
This does not bail when reaching the #F line, but now the first row of data is being ignored. My workaround for that latter problem is to manually set data_start=0, but this should probably be the default behavior.

Activity

  1. embray commented on Jan 21, 2015

    @embray
    Member

    Probably could catch whatever is resulting in that exception and pass on it when guessing. Would help to have the full traceback though (though from the looks of it it sounds like something is trying to match to a regular expression, but not bailing if the match fails). So even if this is too much of a corner case for the guessing to work around, at least that much should be fixed.

  2. hamogu commented on Jan 22, 2015

    @hamogu
    Member

    Thanks for the report @aphearin ! In the end, the guessing just tries out data format and see which one works and if a table is very similar to such a a format, there is a chance that it the guessing fails (if you know the format of your table beforehand, it is always better to avoid guessing, because of performance).
    However, in this case it looks like reading as a DAOphot tables failed and thus the reader should have tried the next alternative.
    I would like to debug this and and fix it.

    Unfortunately, I cannot see the exact format of your table because github renders that as markdown to me (I see bold font and an underline). I don't know how to reverse engeneer the actual ASCII from the rendered format.

    Can you edit your post and enclose the table into triple backticks? Github will then show that as code and not parse it as markdown.

    ```
    table
    table
    table
    ```
    
  3. aphearin commented on Jan 22, 2015

    @aphearin
    Author

    @hamogu - done. Hope this helps track down the bug, let me know if there's anything else I can do. If you'll be working on this in the short term, there's a possibly more serious performance bug in ascii.read() I have found that I will write up and submit shortly and reference in this thread when I do.

  4. hamogu commented on Jan 22, 2015

    @hamogu
    Member

    Thanks, I'll look at that this evening. I think I have a pretty good idea what might be causing this and it's probably a five line fix, so it's unlikely to interfere with anything else.

  5. aphearin commented on Jan 22, 2015

    @aphearin
    Author

    Almost certainly an unrelated problem with ascii.read(), but see also #3334

  6. hamogu commented on Jan 23, 2015

    @hamogu
    Member

    OK, I have a solution for this problem that I will push to github in a minute that causes the guessing to read this table without error. Note, however, that it will read it as a CommentedHeader table so that the result is:

    <Table masked=False length=3>
     some header  info
    int32 int32  int32
    ----- ------ -----
        1      2     3
        4      5     6
        7      8     9
    

    with column names ['some', 'header' 'info']. That is not wrong, although it might not be the expected behaviour in this case. However, there is just no way to algorithmically decide that the table above should have columns that are named col1, col2, col3 automatically (because the first line is a comment) and that the table below should use the first line as column names:

    # star ra dec
    # table taken from my favourite publication
    a 1 2
    b 3 4
    c 5 6
    

    That is what I meant above when I said "In the end, the guessing just tries out data format and see which one works and if a table is very similar to such a a format" then it might or might not read correctly.

  7. added a commit that references this issue on Jan 23, 2015
    e8380c5
  8. aphearin commented on Jan 23, 2015

    @aphearin
    Author

    Nice work @hamogu !

  9. added this to the v1.0.0 milestone on Jan 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions