StringsTableParser

com.phasmidsoftware.tableparser.core.parse.StringsTableParser
abstract class StringsTableParser[Table] extends AbstractTableParser[Table]

Abstract class to extend AbstractTableParser but with Input = Strings This is the unusual situation where a file is a sequence of a sequence of Strings, each representing one value.

Type parameters

Table

the table type.

Attributes

Graph
Supertypes
class AbstractTableParser[Table]
trait TableParser[Table]
trait TableBuilder[Table]
class Object
trait Matchable
class Any
Show all

Members list

Type members

Types

type Input = Strings

The input type, typically String or Strings.

The input type, typically String or Strings.

Attributes

Inherited and Abstract types

type Row

The row type.

The row type.

Attributes

Inherited from:
TableBuilder

Value members

Concrete methods

override def parse(xs: Iterator[Strings], n: Int = ...): Try[Table]

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[Strings].

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[Strings].

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
def parseRows(wss: Iterator[Strings], header: Header): Try[Table]

Parses the rows of a table using the given header and returns the parsed table wrapped in a Try.

Parses the rows of a table using the given header and returns the parsed table wrapped in a Try.

This method processes a sequence of rows (each represented as a Strings), leveraging the provided header and a row parser to translate these rows into a structured table of type Table.

Value parameters

header

the Header object containing metadata about the structure of the table, such as column names.

wss

an Iterator of Strings where each element represents a row (sequence of cell values).

Attributes

Returns

a Try[Table] containing the parsed table on success or an exception on failure.

Inherited methods

def doParseRows(ts: Iterator[Input], header: Header, f: ((Input, Int)) => Try[Row])(using ev: Joinable[Input]): Try[Table]

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 Joinable type class, which defines how input elements can be combined or validated during processing.

f

a transformation function that maps the Header to a function capable of transforming a tuple of input and its index into a Try[Row]. This function encapsulates row processing logic and error handling for each input element.

header

the Header containing column metadata to guide the transformation process.

ts

an iterator of inputs to be parsed into rows.

Attributes

Returns

a Try containing a Table if the parsing is successful, or an error in case of failure.

Inherited from:
AbstractTableParser

Inherited and Abstract methods

protected def builder(rows: Iterator[Row], header: Header): Table

Method to construct a Table based on the given iterator of rows and the given header.

Method to construct a Table based on the given iterator of rows and the given header.

Value parameters

header

a Header object representing the table's column headers.

rows

an iterator of Row objects representing the data rows.

Attributes

Returns

the constructed Table based on the input rows and header.

Inherited from:
TableBuilder

Inherited fields

protected val forgiving: Boolean

If true, individual row failures are logged but do not cause the overall parse to fail.

If true, individual row failures are logged but do not cause the overall parse to fail.

Attributes

Inherited from:
TableBuilder
val headerRowsToRead: Int

This indicates the number of header rows which must be read from the input. The value is usually 1 but some types of CSV file have more than one header line. If maybeHeader exists, then this number is ignored.

This indicates the number of header rows which must be read from the input. The value is usually 1 but some types of CSV file have more than one header line. If maybeHeader exists, then this number is ignored.

CONSIDER if this is really ignored when maybeHeader is defined, then we should eliminate such places where this value has an override of 0.

Attributes

Inherited from:
TableParser
protected val predicate: Try[Row] => Boolean

Predicate to filter rows. Defaults to including all rows.

Predicate to filter rows. Defaults to including all rows.

Attributes

Inherited from:
TableBuilder

Inherited and Abstract fields

Method to define a row parser.

Method to define a row parser.

Attributes

Returns

a RowParser[Row, Input].

Inherited from:
TableParser