bug: read_csv inserts NaN row if file ends in comment line · Issue #10548 · pandas-dev/pandas (original) (raw)

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