mirror of
https://github.com/aselimov/cea-rs.git
synced 2026-04-21 01:14:20 +00:00
15 lines
435 B
Rust
15 lines
435 B
Rust
|
|
pub fn parse_fields(line: &str, widths: &[usize]) -> Vec<String> {
|
||
|
|
let mut fields = Vec::new();
|
||
|
|
let mut pos = 0;
|
||
|
|
|
||
|
|
for &width in widths {
|
||
|
|
if let Some(field) = line.get(pos..pos + width) {
|
||
|
|
// The replace changes the fortran formatted D exponential for the normal E exponential
|
||
|
|
fields.push(field.trim().replace("D", "E").replace("E ", "E"));
|
||
|
|
}
|
||
|
|
pos += width;
|
||
|
|
}
|
||
|
|
|
||
|
|
fields
|
||
|
|
}
|