Skip to main content

read_rows

Function read_rows 

Source
pub fn read_rows(header: &str, rows: &str) -> Result<FlightLog, LogError>
Expand description

Reads the rows of a FIP export whose header line is missing, as in a sheet the export was pasted into below no header, under header: the header line the FIP wrote for that export, which the caller states, such as the 16 channels’ with status columns:

Time@Axial Accel (Gs),Axial Accel (Gs),bILBA,Time@Baro (Atm),Baro (Atm),bILBA,…

The rows are read as read reads them, but for one thing a sheet does: it writes every row as wide as its widest, so a row may end in empty cells past its last channel’s sample. The rows are numbered from 1 in errors, and a first row whose first cell begins with Time, as a header’s first clock name does, is refused: the file has its own, and read reads it.

use hpr_flightdata::raven;

// Invented rows of a two-channel export, the second channel stopped in the last row, and that
// row ended by a sheet's padding.
let header = "Time@Axial Accel (Gs),Axial Accel (Gs),bILBA,\
              Time@[Altitude (Baro-Ft-AGL)],[Altitude (Baro-Ft-AGL)],bILBA";
let rows = "0,1.02,b0000,0,0,b0000\n0.05,1.01,b0000,0.05,1,b0000\n0.1,1.0,b0000,,,\n";
let log = raven::read_rows(header, rows)?;
assert_eq!(log.time_s, [0.0, 0.05]);
assert_eq!(log.channels[0].values.len(), 3);

§Errors

LogError::Mapping when header isn’t a FIP export’s header, as read would refuse it; LogError::Syntax when a row’s first cell is a clock’s name, as a header’s is; and what read refuses in the rows.