| Crates.io | lineio |
| lib.rs | lineio |
| version | 0.1.2 |
| created_at | 2025-03-22 01:50:20.414289+00 |
| updated_at | 2025-03-23 15:13:36.501861+00 |
| description | A simple line reader for files - skipping blank lines and comments |
| homepage | |
| repository | https://github.com/profmadden/lineio |
| max_upload_size | |
| id | 1601463 |
| size | 5,726 |
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.
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);
}
}