Windowing
Windowing lets you control which portion of a file an iterator reads. You can set a byte range, skip a number of items, limit how many items to yield, or align the start to an item boundary
In Rust, these options are set through builder methods:
reader.lines("data.txt")
.start(100)
.end(500)
.skip(2)
.limit(10)
.build()?;
In Python, you pass an IteratorOptions object:
from preader import IteratorOptions
options = IteratorOptions(start=100, end=500, skip=2, limit=10)
reader.lines("data.txt", options=options)
When you use multiple windowing options together, they are applied in this order:
- Byte range (
start,end) restricts the file region - Alignment (
align/align_start) skips the partial first item atstart - Skip discards the first N complete items within the range
- Limit caps how many items are yielded after skipping
This means skip and limit operate within the byte range, not across the entire file
// Read bytes 100-500, skip the first 2 lines in that range, yield at most 10
reader.lines("data.txt")
.start(100)
.end(500)
.align(true)
.skip(2)
.limit(10)
.build()?;
from preader import IteratorOptions
options = IteratorOptions(start=100, end=500, skip=2, limit=10)
reader.lines("data.txt", align_start=True, options=options)
The following pages explain each option and how they interact
- ↔️ Byte Range:
startandendbyte offsets - 🔢 Pagination:
skipandlimitfor item-level control - 📏 Alignment: Handling a start offset that falls mid-item