PickwickSoft / pystreamapi

The Python Stream API Library offering Streams like you know from Java/Kotlin/Scala in Python with some cool extensions
https://pystreamapi.pickwicksoft.org/
GNU General Public License v3.0
30 stars 5 forks source link

CSV loader not lazy #62

Closed garlontas closed 1 year ago

garlontas commented 1 year ago

Describe the bug The CSV loader isn't lazy. It reads the content from the CSV file directly at call.

To Reproduce

from pystreamapi import Stream
from pystreamapi.loaders import csv

stream = Stream.of(csv("/path/to/data.csv")) # CSV is already read here. This is time and memory consuming!
stream.filter(...).map(...).for_each(...) # The terminal operation should actually trigger the CSV reader.

Expected behavior The CSV file should be only read when the iterable (return of csv() function) is accessed.