Skip to main content

parse_mach_csv

Function parse_mach_csv 

Source
pub fn parse_mach_csv(
    text: &str,
    column: Option<&str>,
) -> Result<Table1D, AeroError>
Expand description

Reads a table of a value against Mach number from CSV text.

With column None, the text has two numeric columns (Mach, value), optionally under one header row. With column Some(name), the first non-blank row must be a header; the Mach column is the first whose name contains mach and the value column the one named name (both without regard to case or surrounding space). A column whose name starts with alpha (the angle of attack) selects the rows where it is zero.

A row is a header only if none of its fields is a number. A leading byte-order mark, blank lines, \r\n line ends, quoted fields, trailing commas and leading zeros (01.05) are accepted. A row identical to the one before it is skipped. Otherwise the Mach numbers must be finite and strictly increase: a Mach number repeated with another value, or out of order, is refused, not sorted. The table interpolates linearly and holds its end values outside its range.

§Errors

  • AeroError::Csv naming the 1-based line for a row that doesn’t parse, a missing column or header, a non-finite value, a Mach number that doesn’t increase, or no rows (line 0).
  • AeroError::Table for fewer than two rows.