Crate lineio

Source
Expand description

LineIO is a light-weight line-by-line input library, with the ability to skip over lines that begin with a hash mark, or that are blank.

As part of my research, I deal with a lot of input files that have data organized by line, and with intermixed blank lines and comments. Rather than rebuilding a parser input each time, the functionality is wrapped up in the crate.

There are also convenience functions to turn a line into either a vector of floating point numbers, or a vector of usize, i32, or u32.

While the library is called LineIO, it currently only handles input.

You can use this as follows:

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);
   }
}

Structs§

LineIO
The main structure, which includes an internal buffered reader, and the file handle.