I need to write a Python generator that yields tuples (X, Y) coming from two different CSV files.
It should receive a batch size on init, read line after line from the two CSVs, yield a tuple (X, Y) for each line, where X and Y are arrays (the columns of the CSV files).
I've looked at examples of lazy reading but I'm finding it difficult to convert them for CSVs:
- Lazy Method for Reading Big File in Python?
- Read large text files in Python, line by line without loading it in to memory
Also, unfortunately Pandas Dataframes are not an option in this case.
Any snippet I can start from?
Thanks