Skip to content

bug: read_csv inserts NaN row if file ends in comment line #10548

Closed
@foobarbecue

Description

@foobarbecue

xref #4623

Reading this file produces the expected behavior:

1,2,3
3,8,3
#comment
5,5,5
In [52]: pandas.read_csv('commentBugTest.csv',comment='#')
Out[52]: 
   1  2  3
0  3  8  3
1  5  5  5

However, if the last line in the file is a comment, you get unexpected NaNs:

1,2,3
3,8,3
#comment
In [51]: pandas.read_csv('commentBugTest2.csv',comment='#')
Out[51]: 
    1   2   3
0   3   8   3
1 NaN NaN NaN

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions