lineio

Crates.iolineio
lib.rslineio
version0.1.2
created_at2025-03-22 01:50:20.414289+00
updated_at2025-03-23 15:13:36.501861+00
descriptionA simple line reader for files - skipping blank lines and comments
homepage
repositoryhttps://github.com/profmadden/lineio
max_upload_size
id1601463
size5,726
Patrick H Madden (profmadden)

documentation

README

lineio

Very simple file interface, to parse things a line at a time, skipping blank lines, and lines with a hash mark in the first column.

Lots of EDA input files are line-by-line formatted, with a fixed structure, and comments are with the hash mark. Rather than rebuilding a file reader every time (and having to include the use descriptions, and whatnot), just a simple wrapper. Call getline to get a line, unwrap as needed. The new function takes a string filename.

Example

Here's a simple example of reading in a file.

use lineio::LineIO;

fn main() {
    let mut lineio = match LineIO::new(&"test.txt".to_string()) {
        Ok(reader) => reader,
        Err(error) => {panic!("File opening error: {error:?}");}
    };
    loop {
        let s = match lineio.getline() {
            Ok(str) => str,
            Err(_error) => break,
        };
        println!("Read {}", s);
    }
}
Commit count: 6

cargo fmt