Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Byte Range

The start and end options define a byte range within the file. Only items that begin within this range are yielded

start

The byte offset where reading begins. Default: 0

When resuming from a saved state, if start is beyond the saved position, the position moves forward to start. If the saved position is already past start, the saved position wins

end

The byte offset at which no new item starts. For line and segment iterators, an item that begins before end is yielded in full even if it extends past end. For chunk iterators, the last chunk is truncated to fit within the remaining range. Default: u64::MAX (no limit)

Examples

Rust

let lines = reader.lines("data.txt")
    .start(100)
    .end(500)
    .build()?;

for line in lines {
    println!("{}", line?);
}

Python

from preader import IteratorOptions

options = IteratorOptions(start=100, end=500)

for line in reader.lines("data.txt", options=options):
    print(line)

Setting start greater than end raises an InvalidRange error in Rust and a ValueError in Python