PlainTextHeadedStringTableParser
Case class to define a StringTableParser that assumes a header to be found in the input file. This class attempts to provide as much built-in functionality as possible.
This class assumes that the names of the columns are in the first line. This class implements builder with a HeadedTable object. This class uses StandardRowParser of its rowParser.
Type parameters
- X
-
the underlying row type for which there must be evidence of a CellParser and ClassTag.
Value parameters
- forgiving
-
if true, exceptions when parsing individual rows will be logged then ignored. if false, any exception will terminate the parsing. Defaults to false.
- headerRowsToRead
-
the number of header rows expected in the input file defaults to 1.
- maybeHeader
-
None => requires that the data source has a header row. Some(h) => specifies that the header is to be taken from h. Defaults to None. NOTE: that the simplest is to specify the header directly from the type X.
Attributes
- See also
-
HeadedStringTableParser#create
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass HeadedStringTableParser[X]class Objecttrait Matchableclass AnyShow all
Members list
Type members
Inherited types
The input type, typically String or Strings.
The row type.
Value members
Concrete methods
Configures the parser to operate in a "forgiving" mode, where errors encountered during the parsing of individual rows are logged but do not cause the parsing process to fail. When set to true, the parser will attempt to continue parsing despite encountering errors in the input. When set to false, errors will cause the parsing process to terminate.
Configures the parser to operate in a "forgiving" mode, where errors encountered during the parsing of individual rows are logged but do not cause the parsing process to fail. When set to true, the parser will attempt to continue parsing despite encountering errors in the input. When set to false, errors will cause the parsing process to terminate.
Value parameters
- forgiving
-
a boolean value indicating whether forgiving mode should be enabled.
trueenables forgiving mode, allowing parsing to continue on errors.falsedisables forgiving mode, causing failures on errors.
Attributes
- Returns
-
an instance of
TableParser[Table]configured with the specified forgiving behavior.
Sets a fixed header for the table parser. This method allows the configuration of the parser to use the specified header, instead of deriving it from the data during parsing.
Sets a fixed header for the table parser. This method allows the configuration of the parser to use the specified header, instead of deriving it from the data during parsing.
Value parameters
- header
-
the
Headerinstance representing the fixed header for the table parser, containing column names and optional additional header lines.
Attributes
- Returns
-
a new
TableParser[Table]instance configured with the specified header.
Configures the parser to allow or disallow quoted strings to span across multiple lines.
Configures the parser to allow or disallow quoted strings to span across multiple lines.
When multiline is set to true, the parser permits quoted strings in the input to extend beyond a single line. If set to false, quoted strings are constrained to stay within one line.
Value parameters
- multiline
-
a boolean flag indicating whether multiline parsing of quoted strings is enabled (
true) or disabled (false).
Attributes
- Returns
-
a new
TableParser[Table]instance configured with the updated multiline setting.
Sets a predicate function that determines whether a parsed Row should be included in the final Table. The predicate is applied to each parsed Row wrapped in a Try to allow filtering based on success or failure.
Sets a predicate function that determines whether a parsed Row should be included in the final Table. The predicate is applied to each parsed Row wrapped in a Try to allow filtering based on success or failure.
Value parameters
- predicate
-
a function of type
Try[Row] => Booleanthat accepts aTryof aRowand returnstrueif the row should be included in the table, orfalseotherwise.
Attributes
- Returns
-
a new instance of
TableParser[Table]with the specified predicate applied.
Sets the row parser to be used for parsing rows in the table.
Sets the row parser to be used for parsing rows in the table.
The row parser provides the logic for converting raw input data of type Input into rows of type Row. This method allows you to configure the table parser with a custom row parser, enabling flexibility in interpreting the rows according to specific requirements.
Value parameters
- rowParser
-
the
RowParserinstance to use for parsing rows. TheRowParserdefines how each input (of typeInput) is transformed into a row (of typeRow), potentially using aHeaderfor additional context.
Attributes
- Returns
-
a new
TableParserinstance configured with the specified row parser.
Inherited methods
Parses rows of input data into a table representation.
Parses rows of input data into a table representation.
This method utilizes an IndexedInputToRowsAggregator to transform an iterator of inputs into rows using the provided header and transformation function. It processes the input, materializes the resulting rows into a list, and constructs a table representation from the processed rows and header.
Value parameters
- ev
-
an implicit evidence parameter ensuring the input type adheres to the
Joinabletype class, which defines how input elements can be combined or validated during processing. - f
-
a transformation function that maps the
Headerto a function capable of transforming a tuple of input and its index into aTry[Row]. This function encapsulates row processing logic and error handling for each input element. - header
-
the
Headercontaining column metadata to guide the transformation process. - ts
-
an iterator of inputs to be parsed into rows.
Attributes
- Returns
-
a
Trycontaining aTableif the parsing is successful, or an error in case of failure. - Inherited from:
- AbstractTableParser
Method to parse a table based on a sequence of Inputs. NOTE: this is required so that we can invoke this method with an Iterator[String].
Method to parse a table based on a sequence of Inputs. NOTE: this is required so that we can invoke this method with an Iterator[String].
Value parameters
- n
-
the number of rows to drop (length of the header)--defaults to 1.
- xs
-
the sequence of Inputs, one for each row
Attributes
- Returns
-
a Try[Table].
- Definition Classes
- Inherited from:
- StringTableParser
Parses rows from an iterator of input strings (ws) using the provided header and row parsing logic.
Parses rows from an iterator of input strings (ws) using the provided header and row parsing logic.
This method utilizes the doParseRows function to process each row in the input iterator, applying the provided rowParser.parse function to convert input strings into logical rows, while using the header to guide parsing and interpretation of the input.
Value parameters
- header
-
the
Headerobject that describes the expected structure of the table (e.g., column names). - ws
-
an iterator over the input strings, where each string represents a row in the table.
Attributes
- Returns
-
a
Tryof the parsedTableobject. On success, it contains the resulting table; on failure, it contains the parsing error. - Inherited from:
- StringTableParser
Method to parse the input into a Table of the selected rows (see rows). As in parse, if this parser isn't forgiving, a row which can't be parsed makes the result a Failure.
Method to parse the input into a Table of the selected rows (see rows). As in parse, if this parser isn't forgiving, a row which can't be parsed makes the result a Failure.
Value parameters
- n
-
the number of header lines (defaults to headerRowsToRead).
- selection
-
the rows to select (RFC 7111: see CsvFragment).
- xs
-
the lines of the input.
Attributes
- Returns
-
a Try[Table].
- Inherited from:
- StringTableParser
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
Method to parse the input lazily, as a stream of rows rather than a Table (see, e.g., IOTable.stream). The header is read now (from the first n lines, unless this parser has a fixed header); each row is parsed only when it is pulled from the iterator. As in parse, the predicate selects the rows; and, if this parser is forgiving, a row which can't be parsed is logged and left out. Otherwise, it is a Failure in the iterator.
Method to parse the input lazily, as a stream of rows rather than a Table (see, e.g., IOTable.stream). The header is read now (from the first n lines, unless this parser has a fixed header); each row is parsed only when it is pulled from the iterator. As in parse, the predicate selects the rows; and, if this parser is forgiving, a row which can't be parsed is logged and left out. Otherwise, it is a Failure in the iterator.
The selection (of RFC 7111 rows: see CsvFragment) applies before the predicate, since its row numbers are those of the input.
Value parameters
- n
-
the number of header lines (defaults to headerRowsToRead).
- selection
-
the rows to select (by default, all of them).
- xs
-
the lines of the input.
Attributes
- Returns
-
a Try of the header and an Iterator of the rows (each a Try).
- Inherited from:
- StringTableParser
Inherited fields
Predicate to filter rows. Defaults to including all rows.
Method to define a row parser.
Method to define a row parser.
Attributes
- Returns
-
a RowParser[Row, Input].
- Inherited from:
- HeadedStringTableParser