Skip to main content

read_rows_around

Function read_rows_around 

Source
pub fn read_rows_around(
    header: &str,
    rows: &str,
    pasted: &[usize],
) -> Result<FlightLog, LogError>
Expand description

Reads the rows of a FIP export whose header line is missing, as read_rows does, from a sheet whose columns pasted, numbered from 1, hold another table pasted over the export’s cells. A stopped channel shifts every channel after it one cell to the left, so a column of the sheet holds different channels’ cells in different rows, and a pasted column hides a cell of whichever channel is there.

The rule: a channel whose sample, in any row, has a cell in a pasted column is left out whole, with a note naming it and counting the rows; every other channel is read as read_rows reads it. To walk a row, each channel’s cells must still say whether it has a sample: one of its time’s and values’ cells outside the pasted columns not empty; or, where some are pasted over and the rest empty, and the channel has its own clock and a status, the cell after them, a sample’s status, b and digits, where a stopped channel’s next cell is another channel’s time. That cell pasted over or empty, a status left empty or another channel stopped too, or a clock of more channels, the row is refused.

use hpr_flightdata::raven;

// Invented rows of a three-channel export whose fourth and fifth columns another table was
// pasted over, 7 and 8: the second channel is left out.
let header = "Time@Axial Accel (Gs),Axial Accel (Gs),bILBA,\
              Time@Baro (Atm),Baro (Atm),bILBA,\
              Time@[Altitude (Baro-Ft-AGL)],[Altitude (Baro-Ft-AGL)],bILBA";
let rows = "0,1.02,b0000,7,8,b0000,0,0,b0000\n0.05,1.01,b0000,7,8,b0000,0.05,1,b0000\n";
let log = raven::read_rows_around(header, rows, &[4, 5])?;
assert_eq!(log.channels.len(), 4);
assert_eq!(log.time_s, [0.0, 0.05]);

§Errors

As read_rows’s; and LogError::Syntax for a row in which the pasted cells hide whether a channel has a sample, and LogError::Mapping for a pasted column numbered 0.