Skip to content

read_csv with iterator=True does not seem to work as expected without chunksize #3967

Closed
@garaud

Description

@garaud

Hi there,

I tested:

data = """A,B,C
foo,1,2,3
bar,4,5,6
baz,7,8,9
"""
reader = pd.read_csv(StringIO(data), iterator=True)

I thought that I could do:

for row in reader:
    print(row)

since reader is iterable. Unfortunately, it calls the generator TextFileReader.__iter__:

def __iter__(self):
    try:
        while True:
            yield self.read(self.chunksize)
    except StopIteration:
        pass

where self.chunksize is None. Maybe set self.chunsize to 1 when it's not
defined and there is iterator=True. I'll propose a patch as soon as possible
--- today or tomorrow.

Best regards,
Damien G.

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