Skip to content

c-parser branch: Iteration over an open file handle makes the parser fail #2071

Closed
@lbeltrame

Description

@lbeltrame

An example is better than words:

In [16]: cat test.txt
AAA
BBB
CCC
DDD
EEE
FFF
GGG

In [17]: with open("test.txt") as handle:                      
    iterator = itertools.islice(handle, 3)
    print list(iterator)
    res = pandas.read_table(handle, squeeze=True, header=None)
   ....:     
['AAA\n', 'BBB\n', 'CCC\n']

In [18]: res
Out[18]: 
Empty DataFrame
Columns: array([], dtype=object)
Index: array([], dtype=object)

This works with the python engine. Notice that the handle is not really iterated through: when debugging I noticed that after iterator usage, the handle keeps on staying at the same file line (IOW the parser is not iterating on it at all).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions