com.phasmidsoftware.tableparser.core.parse

Members list

Type members

Classlikes

abstract class AbstractRowProcessor[Row] extends RowProcessor[Row]

Abstract class representing a row processor for handling input rows and parsing them into a specified row type.

Abstract class representing a row processor for handling input rows and parsing them into a specified row type.

This class extends the RowProcessor type class and provides additional methods for processing iterators of input rows based on headers and transformation functions. It relies on the implicit evidence of the Joinable type class to define behavior for handling the input type.

Type parameters

Row

the type of rows output by this processor.

Attributes

Supertypes
trait RowProcessor[Row]
class Object
trait Matchable
class Any
Known subtypes
class StringRowProcessor[Row]

The AbstractTableParser companion object provides utility methods for logging exceptions during the table parsing process.

The AbstractTableParser companion object provides utility methods for logging exceptions during the table parsing process.

This object includes methods to log exceptions, whether they are directly provided as a Throwable or wrapped inside a Try result.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class AbstractTableParser[Table] extends TableParser[Table]

Abstract base class for implementations of TableParser[T]. NOTE: that Table is a parametric type and does NOT refer to the type Table defined elsewhere.

Abstract base class for implementations of TableParser[T]. NOTE: that Table is a parametric type and does NOT refer to the type Table defined elsewhere.

CONSIDER making this a trait

Type parameters

Table

the (parametric) Table type.

Attributes

Companion
object
Supertypes
trait TableParser[Table]
trait TableBuilder[Table]
class Object
trait Matchable
class Any
Known subtypes

The AttributeSet object provides utility methods for constructing and parsing instances of the AttributeSet class. This is primarily used for handling a column in a table that represents a set of attributes, typically formatted as a comma-separated list, and potentially enclosed in brackets or other separators.

The AttributeSet object provides utility methods for constructing and parsing instances of the AttributeSet class. This is primarily used for handling a column in a table that represents a set of attributes, typically formatted as a comma-separated list, and potentially enclosed in brackets or other separators.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
trait CsvRenderers
trait CellParsers
class Object
trait Matchable
class Any
Show all
Self type
case class AttributeSet(xs: StringList)

This class is used for the situation where a column in a table actually contains a set of attributes, typically separated by "," and possibly bracketed by "{}". CONSIDER allowing "|" as a separator (as described previously in the documentation here).

This class is used for the situation where a column in a table actually contains a set of attributes, typically separated by "," and possibly bracketed by "{}". CONSIDER allowing "|" as a separator (as described previously in the documentation here).

Value parameters

xs

the attribute values.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class BlankException(e: Throwable = ...) extends ParseableException

A case class representing a specific exception type BlankException used when a blank value or an error associated with a blank value is encountered during the parsing process. It extends ParseableException as its base type.

A case class representing a specific exception type BlankException used when a blank value or an error associated with a blank value is encountered during the parsing process. It extends ParseableException as its base type.

Value parameters

e

an optional Throwable cause associated with the exception. Defaults to null if not provided.

Attributes

Constructor

Creates a new BlankException by delegating to the base ParseableException and providing the message identifier "blank" along with the optional cause e.

Example
// Throwing a BlankException with a cause
throw BlankException(new IllegalArgumentException("Blank value encountered"))
// Throwing a BlankException without a cause
throw BlankException()
Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
trait CellParser[+T] extends StringConverter[T]

Type-class trait CellParser[T]. This trait has methods to parse and to convert from String to T.

Type-class trait CellParser[T]. This trait has methods to parse and to convert from String to T.

TODO Need to define this better so that we don't have any non-implemented methods.

Type parameters

T

the (covariant) type of the resulting object.

Attributes

Companion
object
Supertypes
trait StringConverter[T]
class Object
trait Matchable
class Any
Known subtypes
object CellParser

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
CellParser.type
trait CellParsers

Trait to define the various parsers for reading case classes and their parameters from table rows.

Trait to define the various parsers for reading case classes and their parameters from table rows.

NOTE: In each of these cellParser methods, the CellParser has a parse method which ignores the columns.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class CellValue(w: String) extends Convertible

A concrete Convertible corresponding to a cell value.

A concrete Convertible corresponding to a cell value.

Value parameters

w

the String contained by a cell.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Convertible
class Object
trait Matchable
class Any
Show all
object ColumnHelper

Object containing utility functions for mapping and transforming column names, providing multiple default strategies for common transformations.

Object containing utility functions for mapping and transforming column names, providing multiple default strategies for common transformations.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait ColumnHelper[T]

Type class representing a mapping from a case class parameter to the corresponding column header.

Type class representing a mapping from a case class parameter to the corresponding column header.

Type parameters

T

the type of the object being helped.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
class ConditionalCellParser[K, P, T](typeName: String, fields: List[String], construct: (K, P) => T, parsers: Map[K, CellParser[P]])(using kp: CellParser[K], helper: ColumnHelper[T]) extends MultiCellParser[T]

The CellParser made by CellParsers.cellParser2Conditional.

The CellParser made by CellParsers.cellParser2Conditional.

Type parameters

K

the type of the first field of T.

P

the type of the second field of T.

T

the type of the result.

Value parameters

construct

a function (K,P) => T.

fields

the names of the two fields of T.

parsers

the parser of P to use for each value of K.

typeName

the name of T (used in error messages).

Attributes

Supertypes
trait MultiCellParser[T]
trait CellParser[T]
trait StringConverter[T]
class Object
trait Matchable
class Any
Show all
sealed trait Convertible

Trait Convertible.

Trait Convertible.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CellValue
class RowValues
trait CopyableTableParser[Row, Input, Table]

A trait representing a parser for tables that supports configurability and row-level parsing.

A trait representing a parser for tables that supports configurability and row-level parsing.

The CopyableTableParser provides methods to configure the parsing behavior of tables, such as defining headers, enabling forgiving or multiline parsing modes, setting predicates for row filtering, and defining custom row parsing logic. It operates generically over three types: Row, representing a single row in the table; Input, representing raw input data for parsing rows; and Table, representing the parsed table as a whole.

Type parameters

Input

the type of the raw input data used to parse rows.

Row

the type of a single row in the table.

Table

the type of the parsed table.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class HeadedCSVTableParser[T](using rp: RowParser[T, String]) extends StringTableParser[Table[T]]

Abstract class for parsing tables from CSV-formatted strings, where the table has a defined header. This is the most convenient subtype of TableParser for most CSV files.

Abstract class for parsing tables from CSV-formatted strings, where the table has a defined header. This is the most convenient subtype of TableParser for most CSV files.

Type parameters

T

the parametric type of rows in the table.

Value parameters

rp

an implicit RowParser, which defines the logic for parsing individual rows of type T from strings.

Attributes

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

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class HeadedStringTableParser[X](maybeFixedHeader: Option[Header] = ..., val forgiving: Boolean = ..., val headerRowsToRead: Int = ...)(using evidence$1: CellParser[X]) extends StringTableParser[Table[X]], CopyableTableParser[X, String, Table[X]]

Abstract class to define a StringTableParser that assumes a header to be found in the input file. There are two subclasses: PlainTextHeadedStringTableParser and EncryptedHeadedStringTableParser This class attempts to provide as much built-in functionality as possible.

Abstract class to define a StringTableParser that assumes a header to be found in the input file. There are two subclasses: PlainTextHeadedStringTableParser and EncryptedHeadedStringTableParser 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.

NOTE that this class and HeadedCSVTableParser are extremely similar (maybe identical) CONSIDER merging with HeadedCSVTableParser

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.

maybeFixedHeader

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

Companion
object
Supertypes
trait CopyableTableParser[X, String, Table[X]]
trait TableParser[Table[X]]
trait TableBuilder[Table[X]]
class Object
trait Matchable
class Any
Show all
Known subtypes
class IndexedInputToRowsAggregator[Input, Row](f: ((Input, Int)) => Try[Row], multiline: Boolean, forgiving: Boolean, predicate: Try[Row] => Boolean)(using evidence$1: Joinable[Input]) extends InputAggregator[Input, Row, Try]

The IndexedInputToRowsAggregator class provides functionality to process and aggregate input data of type Input into structured rows of type Row, with support for error handling, validation, and conditional processing. It extends the abstract class InputAggregator.

The IndexedInputToRowsAggregator class provides functionality to process and aggregate input data of type Input into structured rows of type Row, with support for error handling, validation, and conditional processing. It extends the abstract class InputAggregator.

The class leverages implicit Joinable behavior for Input and works with Try to handle potential failures during the transformation of input data into rows. The flexibility is further increased with options to apply a custom predicate to filter rows, enable forgiving behavior (ignoring failures), and process multi-line inputs.

Type parameters

Input

the type of input elements to be processed.

Row

the type of rows transformed from the input.

Value parameters

f

a function that takes a tuple of (Input, Int) and returns a Try[Row], used to transform each input element and its index into a Row.

forgiving

a flag indicating whether forgiving behavior is enabled (i.e., failures are logged and ignored rather than propagated).

multiline

a flag indicating whether multi-line input processing is enabled.

predicate

a function that takes a Try[Row] and returns a boolean, used to filter processed rows based on custom validation logic.

Attributes

Supertypes
class InputAggregator[Input, Row, Try]
trait InputPreprocessor[Input, Row]
class Object
trait Matchable
class Any
class IndexedInputToRowsTransformer[Input, Row](f: ((Input, Int)) => Try[Row], multiline: Boolean)(using evidence$1: Joinable[Input]) extends InputTransformer[Input, Row]

A transformer class designed to map and process inputs to rows while handling indexed inputs.

A transformer class designed to map and process inputs to rows while handling indexed inputs.

This class extends InputTransformer and provides functionality to apply a transformation defined by a function f to indexed inputs ((Input, Int)), processing the resulting Try[Row] instances to either extract valid Row results or handle errors using logging.

Type parameters

Input

The type of input elements to be processed. Must have an implicit Joinable[Input] defined.

Row

The type of rows produced after transformation.

Value parameters

f

A function that takes an (Input, Int) tuple and maps it to a Try[Row], representing the transformation logic from input to row with error handling.

multiline

A boolean flag indicating whether the transformation operates in a multiline mode.

Attributes

Supertypes
class InputTransformer[Input, Row]
trait InputPreprocessor[Input, Row]
class Object
trait Matchable
class Any
abstract class InputAggregator[Input, Row, Wrapper[_]]() extends InputPreprocessor[Input, Row]

The InputAggregator abstract class extends the InputPreprocessor trait to provide additional higher-level processing functionality for input data. It focuses on aggregating and processing transformed rows encapsulated in Try, with support for filtering invalid or failed transformations and wrapping the successfully processed rows in a desired container type Wrapper[_].

The InputAggregator abstract class extends the InputPreprocessor trait to provide additional higher-level processing functionality for input data. It focuses on aggregating and processing transformed rows encapsulated in Try, with support for filtering invalid or failed transformations and wrapping the successfully processed rows in a desired container type Wrapper[_].

This class serves as an abstraction for handling the pipeline of parsing, processing, and aggregating data within a flexible and reusable structure, designed to be used in applications that involve parsing and pre-processing input data into structured forms.

Type parameters

Input

the type of input elements to be processed, such as raw data or records.

Row

the type of rows that result from processing the inputs, typically structured representations.

Wrapper

the container type used to wrap the successfully processed rows, e.g., Option, Either, or List.

Attributes

Supertypes
trait InputPreprocessor[Input, Row]
class Object
trait Matchable
class Any
Known subtypes
class IndexedInputToRowsAggregator[Input, Row]
trait InputMapper[Input, Row] extends Input => Try[Row]

A trait that defines a contract for mapping an input of type Input to a row of type Row as a computation that can either succeed or fail, represented by Try[Row].

A trait that defines a contract for mapping an input of type Input to a row of type Row as a computation that can either succeed or fail, represented by Try[Row].

InputMapper is designed to abstract the process of parsing or transforming an input into a structured row representation, where the input may come from any external or internal source and the row represents a meaningful structured output.

NOTE this does not handle sequenced input. If you potentially need to handle sequenced input, use InputPreprocessor instead.

Type parameters

Input

the type of input that will be processed or parsed (e.g., raw data).

Row

the type of the resulting row produced by the mapping (e.g., structured data).

Attributes

Supertypes
trait Input => Try[Row]
class Object
trait Matchable
class Any
trait InputPreprocessor[Input, Row]

A trait for preprocessing input data elements into rows, representing an early stage in data transformation pipelines. The InputPreprocessor trait defines a contract for mapping input data of type Input into rows of type Row, encapsulated in Try to handle processing outcomes.

A trait for preprocessing input data elements into rows, representing an early stage in data transformation pipelines. The InputPreprocessor trait defines a contract for mapping input data of type Input into rows of type Row, encapsulated in Try to handle processing outcomes.

This abstraction is intended to facilitate robust and reusable data-parsing workflows, allowing the encapsulation of individual transformations or mappings with error-handling functionality. Implementations of this trait can provide specific strategies or rules for transforming input into rows, effectively bridging raw input data and downstream processing.

Type parameters

Input

the type of input elements to be processed, e.g., raw data points or records.

Row

the type of rows to be produced by the mapping, e.g., structured representations of the input (such as case classes or key-value mappings).

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class InputAggregator[Input, Row, Wrapper]
class IndexedInputToRowsAggregator[Input, Row]
class InputTransformer[Input, Row]
class IndexedInputToRowsTransformer[Input, Row]
abstract class InputTransformer[Input, Row]() extends InputPreprocessor[Input, Row]

An abstract class InputTransformer that extends InputPreprocessor and defines methods for transforming input data into rows, including error handling and extracting valid data rows.

An abstract class InputTransformer that extends InputPreprocessor and defines methods for transforming input data into rows, including error handling and extracting valid data rows.

This class provides a scaffold for implementing data preprocessing pipelines by utilizing input-to-row transformations (mapTsToRows) and processing the results to extract valid rows while disregarding or handling errors (processTriedRows). It facilitates robust and reusable approaches in data processing workflows, making it easier to define reusable transformation logic for specific input data types and row structures.

Type parameters

Input

the type of input elements to be processed, for example, raw data records or strings.

Row

the type of rows to be produced after transformation, typically structured representations like case classes or tuples.

Attributes

Supertypes
trait InputPreprocessor[Input, Row]
class Object
trait Matchable
class Any
Known subtypes
class IndexedInputToRowsTransformer[Input, Row]
case class InvalidParseException(msg: String, e: Throwable = ...) extends ParseableException

A case class representing an exception that occurs when a parsing error is encountered and the parsing operation fails to produce a valid result.

A case class representing an exception that occurs when a parsing error is encountered and the parsing operation fails to produce a valid result.

This exception is a specialized form of ParseableException.

Value parameters

e

An optional Throwable cause for the exception (default is null).

msg

A string message providing details about the parsing error.

Attributes

Constructor

Creates an instance of InvalidParseException.

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
object LineParser

Companion object for the LineParser class, responsible for constructing instances of LineParser and providing logging capabilities.

Companion object for the LineParser class, responsible for constructing instances of LineParser and providing logging capabilities.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
LineParser.type
class LineParser(delimiter: Regex, string: Regex, enclosures: String, listSeparator: Char, quote: Char, verbose: Boolean = ...) extends JavaTokenParsers

LineParser: class to parse lines of a CSV file. NOTE: list elements always appear as a string in the form { element0 , element1 , ... }

LineParser: class to parse lines of a CSV file. NOTE: list elements always appear as a string in the form { element0 , element1 , ... }

Value parameters

delimiter

a Regex used to match a delimiter between cells in a row.

enclosures

the enclosure characters around a list (if any).

listSeparator

the list separator character.

quote

the quote character which is able to preempt the string regex: between two quote characters, there can be any number of any character (other than quote).

string

a Regex used to match the content of a cell.

verbose

will print the various parameters.

Attributes

Companion
object
Supertypes
trait JavaTokenParsers
trait RegexParsers
trait Parsers
class Object
trait Matchable
class Any
Show all
object ListParser extends JavaTokenParsers

This object is a parser of lists. A list is considered to be enclosed by {} and separated by commas.

This object is a parser of lists. A list is considered to be enclosed by {} and separated by commas.

Attributes

Supertypes
trait JavaTokenParsers
trait RegexParsers
trait Parsers
class Object
trait Matchable
class Any
Show all
Self type
ListParser.type
trait MultiCellParser[T] extends CellParser[T]

CONSIDER renaming this to something like RowParser, or RawRowParser.

CONSIDER renaming this to something like RowParser, or RawRowParser.

Type parameters

T

the type of the result.

Attributes

Supertypes
trait CellParser[T]
trait StringConverter[T]
class Object
trait Matchable
class Any
Known subtypes
class ConditionalCellParser[K, P, T]
case class MultiLineException[X](x: X) extends Exception

The MultiLineException class is a case class that extends the Exception class. This exception is designed to handle multi-line exception scenarios where custom content is provided to describe the error.

The MultiLineException class is a case class that extends the Exception class. This exception is designed to handle multi-line exception scenarios where custom content is provided to describe the error.

Type parameters

X

The generic type of the content that can represent the cause or context of the exception. The exception message is constructed dynamically by concatenating the string "multi-line exception: " with the provided content. Usage example:

val exception = MultiLineException("An error occurred")
throw exception

Value parameters

x

The content of type X that describes the exception or provides context for it.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case class ParseLogicException(msg: String, e: Throwable = ...) extends Exception

Exception class representing an error encountered during parsing logic.

Exception class representing an error encountered during parsing logic.

This exception is used to indicate situations where parsing fails due to some issue in the business or logical rules during the process of parsing data.

Value parameters

e

The underlying cause of the exception, if any. Defaults to null if no specific cause is provided.

msg

A descriptive message providing information about the error. This message is used to help diagnose the cause of the parsing failure.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
trait Parseable[T]

Type class which describes a type which can be parsed from a String.

Type class which describes a type which can be parsed from a String.

Type parameters

T

the resulting type.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Parseable

The Parseable object provides a set of predefined Parseable type class instances that enable parsing of String representations into instances of various data types. These parsers operate based on the Parseable[T] trait, which defines a parse method that returns a Try[T].

The Parseable object provides a set of predefined Parseable type class instances that enable parsing of String representations into instances of various data types. These parsers operate based on the Parseable[T] trait, which defines a parse method that returns a Try[T].

This framework is designed to handle common data parsing scenarios with support for additional parsing behaviors through optional modifiers.

The parsers handle parsing errors gracefully, returning a Failure instance with an appropriate exception message when parsing fails.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Parseable.type
abstract class ParseableException(msg: String, e: Throwable = ...) extends Exception

Abstract class ParseableException is an extension of the standard Scala Exception class and provides a base structure for defining custom exceptions that can carry a parse error message and an optional cause (a Throwable).

Abstract class ParseableException is an extension of the standard Scala Exception class and provides a base structure for defining custom exceptions that can carry a parse error message and an optional cause (a Throwable).

This class can be used as a foundation for defining exceptions when parsing operations fail or encounter errors, allowing informative and structured error reporting.

Value parameters

e

an optional throwable that caused this exception, defaulting to null if not provided.

msg

the error message detailing the cause or nature of the parsing issue.

Attributes

Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes

The ParseableOption object provides implicit instances of ParseableOption for various types, enabling the parsing of optional Scala values.

The ParseableOption object provides implicit instances of ParseableOption for various types, enabling the parsing of optional Scala values.

ParseableOption works in conjunction with the abstract class of the same name, allowing strings to be parsed into optional values of specified types while handling blanks as None. This is achieved through the underlying Parseable evidence available for the corresponding type.

The implicit objects defined here provide type-specific implementations for common data types like String, Int, Boolean, LocalDate, and more.

These implicit objects are particularly useful in scenarios involving generic parsing where the target type is optional, and blanks should not raise errors but return None.

Example:

import com.phasmidsoftware.tableparser.core.parse._
import ParseableOption._

val maybeInt: Try[Option[Int]] = summon[Parseable[Option[Int]]].parse("42", None)
val maybeNone: Try[Option[Int]] = summon[Parseable[Option[Int]]].parse("", None)

The implicit instances provided:

  • ParseableOptionString: Parses optional String
  • ParseableOptionBoolean: Parses optional Boolean
  • ParseableOptionByte: Parses optional Byte
  • ParseableOptionShort: Parses optional Short
  • ParseableOptionInt: Parses optional Int
  • ParseableOptionFloat: Parses optional Float
  • ParseableOptionDouble: Parses optional Double
  • ParseableOptionLong: Parses optional Long
  • ParseableOptionBigInt: Parses optional BigInt
  • ParseableOptionBigDecimal: Parses optional BigDecimal
  • ParseableOptionLocalDate: Parses optional LocalDate
  • ParseableOptionURL: Parses optional java.net.URL
  • ParseableOptionFile: Parses optional java.io.File

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class ParseableOption[T] extends Parseable[Option[T]]

Abstract class to parse optional scala values.

Abstract class to parse optional scala values.

Type parameters

T

the resulting type for which there must be evidence of a Parseable[T].

Attributes

Companion
object
Supertypes
trait Parseable[Option[T]]
class Object
trait Matchable
class Any
Known subtypes
case class ParserException(msg: String, e: Throwable = ...) extends Exception

Represents an exception that occurs during parsing operations.

Represents an exception that occurs during parsing operations.

Value parameters

e

the underlying throwable that caused this exception (optional, defaults to null).

msg

the message describing the cause of the exception.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case class PlainTextHeadedStringTableParser[X](maybeHeader: Option[Header] = ..., forgiving: Boolean = ..., headerRowsToRead: Int = ...)(using evidence$1: CellParser[X]) extends HeadedStringTableParser[X]

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.

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

Supertypes
trait Serializable
trait Product
trait Equals
trait CopyableTableParser[X, String, Table[X]]
trait TableParser[Table[X]]
trait TableBuilder[Table[X]]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class ProductCellParser[T](typeName: String, fieldNames: List[String], fieldParsers: List[CellParser[_]], construct: Seq[Any] => T)(using helper: ColumnHelper[T]) extends MultiCellParser[T]

The CellParser of a case class T, as derived by CellParser.derived.

The CellParser of a case class T, as derived by CellParser.derived.

Type parameters

T

the type of the result.

Value parameters

construct

a function to construct a T from the values of its fields.

fieldNames

the names of the fields of T, in declaration order.

fieldParsers

the CellParsers of the fields of T, in the same order.

helper

the ColumnHelper[T] which maps field names to column names.

typeName

the name of T (used in error messages).

Attributes

Companion
object
Supertypes
trait MultiCellParser[T]
trait CellParser[T]
trait StringConverter[T]
class Object
trait Matchable
class Any
Show all
object RawParsers

Object RawParsers provides utility instances for parsing raw data represented as sequences of strings. Specifically, it provides pre-configured parsers for handling different use cases.

Object RawParsers provides utility instances for parsing raw data represented as sequences of strings. Specifically, it provides pre-configured parsers for handling different use cases.

Example use cases include parsing data with a pre-defined header row.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
RawParsers.type
abstract class RawParsers(optionalHeader: Option[Header], forgiving: Boolean = ..., headerRows: Int = ...) extends CellParsers

Abstract class to define a raw parser, that's to say a Parser of Seq[String]

Abstract class to define a raw parser, that's to say a Parser of Seq[String]

Value parameters

forgiving

true if we want this parser to be forgiving (defaults to false).

optionalHeader

a header if appropriate.

Attributes

Companion
object
Supertypes
trait CellParsers
class Object
trait Matchable
class Any
Known subtypes
object WithHeaderRow
Self type
case class RawTableParser(predicate: Try[RawRow] => Boolean = ..., maybeHeader: Option[Header] = ..., forgiving: Boolean = ..., multiline: Boolean = ..., headerRowsToRead: Int = ...) extends StringTableParser[RawTable], CopyableTableParser[RawRow, String, RawTable]

Class used to parse files as a Table of Seq[String]. That's to say, no parsing of individual (or groups of) columns.

Class used to parse files as a Table of Seq[String]. That's to say, no parsing of individual (or groups of) columns.

Value parameters

forgiving

forcing (defaults to true). If true then an individual malformed row will not prevent subsequent rows being parsed.

maybeHeader

an optional fixed header. If None, we expect to find the header defined in the first line of the file.

predicate

a predicate which, if true, allows inclusion of the input row.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object RowConfig

Companion object to RowConfig.

Companion object to RowConfig.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
RowConfig.type
case class RowConfig(delimiter: Char = ..., quote: Char = ..., listSep: Char = ..., listEnclosure: String = ..., trim: Boolean = ..., maybeString: Option[Regex] = ...)

Case class to define the configuration for parsing a row (see LineParser).

Case class to define the configuration for parsing a row (see LineParser).

The default reads CSV as defined by RFC 4180 (https://www.rfc-editor.org/rfc/rfc4180): fields are separated by commas, and spaces are part of a field; a field may be quoted (with "), in which case it may contain commas, line breaks and quotes (which are doubled).

The regular expressions which LineParser uses are derived from the characters, so that changing the delimiter (for example) changes everything that depends on it. Use the copy methods (withDelimiter, etc.) to change one property, e.g. given RowConfig = RowConfig.default.withDelimiter('\t') or simply given RowConfig = RowConfig(delimiter = '\t').

Value parameters

delimiter

the character which separates fields. Defaults to ','.

listEnclosure

the (two) characters which enclose a list within a field, or "" if lists are not enclosed. Defaults to "{}".

listSep

the character which separates the elements of a list within a field. Defaults to '|'.

maybeString

an explicit Regex for a field which is not quoted, if the default (any characters other than the delimiter and the quote) is not wanted.

quote

the character which encloses a quoted field. Defaults to '"'.

trim

if true, any spaces next to a delimiter are ignored (so that "a, b" has the fields "a" and "b"), as in 1.x; this is not RFC 4180. Defaults to false.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait RowParser[Row, Input]

Trait to describe a parser which will yield a Try[Row] from a String representing a row of a table.

Trait to describe a parser which will yield a Try[Row] from a String representing a row of a table.

Type parameters

Input

the (parametric) Input type for which there must be evidence of a RowParser[Row, Input].

Row

the (parametric) Row type for which there must be evidence of a RowParser[Row, Input].

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait StringParser[Row]
class StandardRowParser[Row]
trait StringsParser[Row]
trait RowProcessor[Row]

Typeclass trait representing a row processor that defines how rows of input data can be parsed into specific types, typically useful for parsing and processing tabular data with headers. CONSIDER finding a common super-type between this and TableParser.

Typeclass trait representing a row processor that defines how rows of input data can be parsed into specific types, typically useful for parsing and processing tabular data with headers. CONSIDER finding a common super-type between this and TableParser.

Type parameters

Row

the type that each row will be processed into.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class RowProcessorException(msg: String, e: Option[Throwable] = ...) extends Exception

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
object RowValues

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
RowValues.type
case class RowValues(row: Row, header: Header) extends Convertible

A concrete Convertible corresponding to a row.

A concrete Convertible corresponding to a row.

Value parameters

header

the Header.

row

the Row containing several values.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Convertible
class Object
trait Matchable
class Any
Show all
trait SingleCellParser[T] extends CellParser[T]

Trait SingleCellParser, which extends CellParser[T].

Trait SingleCellParser, which extends CellParser[T].

Type parameters

T

the type of the resulting object.

Attributes

Supertypes
trait CellParser[T]
trait StringConverter[T]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
case class StandardRowParser[Row](parser: LineParser)(using evidence$1: CellParser[Row]) extends StringParser[Row]

StandardRowParser: a parser which extends RowParser[Row] and will yield a Try[Row] from a String representing a line of a table.

StandardRowParser: a parser which extends RowParser[Row] and will yield a Try[Row] from a String representing a line of a table.

Type parameters

Row

the (parametric) Row type for which there must be evidence of a CellParser[Row].

Value parameters

parser

the LineParser to use

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait StringParser[Row]
trait RowParser[Row, String]
class Object
trait Matchable
class Any
Show all
case class StandardStringsParser[Row]()(using evidence$1: CellParser[Row]) extends StringsParser[Row]

StandardRowParser: a parser which extends RowParser[Row] and will yield a Try[Row] from a String representing a line of a table.

StandardRowParser: a parser which extends RowParser[Row] and will yield a Try[Row] from a String representing a line of a table.

Type parameters

Row

the (parametric) Row type for which there must be evidence of a CellParser[Row].

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait StringsParser[Row]
trait RowParser[Row, Strings]
class Object
trait Matchable
class Any
Show all
object StdCellParsers extends CellParsers

TODO resolve the naming issue here.

TODO resolve the naming issue here.

Attributes

Supertypes
trait CellParsers
class Object
trait Matchable
class Any
Self type
trait StringConverter[+T]

Trait to convert a String into a T (see CellParser, which extends it).

Trait to convert a String into a T (see CellParser, which extends it).

NOTE: up to 2.0, the companion object had instances for the basic types, but nothing used them (CellParser's own instances are found instead).

Type parameters

T

the type of the result.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait StringParser[Row] extends RowParser[Row, String]

A RowParser whose input type is String.

A RowParser whose input type is String.

Type parameters

Row

the (parametric) Row type for which there must be evidence of a RowParser[Row, Input].

Attributes

Supertypes
trait RowParser[Row, String]
class Object
trait Matchable
class Any
Known subtypes
class StandardRowParser[Row]
abstract class StringRowProcessor[Row](using rp: RowParser[Row, String]) extends AbstractRowProcessor[Row]

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

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

Type parameters

Row

the row type.

Attributes

Supertypes
trait RowProcessor[Row]
class Object
trait Matchable
class Any
abstract class StringTableParser[Table] extends AbstractTableParser[Table]

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

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

Type parameters

Table

the table type.

Attributes

Supertypes
class AbstractTableParser[Table]
trait TableParser[Table]
trait TableBuilder[Table]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait StringsParser[Row] extends RowParser[Row, Strings]

Trait to describe a parser which will yield a Try[Row] from a sequence of Strings representing a row of a table.

Trait to describe a parser which will yield a Try[Row] from a sequence of Strings representing a row of a table.

Type parameters

Row

the (parametric) Row type for which there must be evidence of a CellParser[Row].

Attributes

Supertypes
trait RowParser[Row, Strings]
class Object
trait Matchable
class Any
Known subtypes
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.

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

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

Minimal trait expressing the table-building contract, independent of how the input source is read.

Minimal trait expressing the table-building contract, independent of how the input source is read.

TableParser extends this for string-based sources. ParquetTableParser extends this directly for Parquet sources. Future source types (JDBC ResultSet, JSON, etc.) can do the same.

Type parameters

Table

the table type to be built.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object TableParser

The TableParser object provides functionality for parsing tabular data from various sources using a StringTableParser. It includes utilities for character-by-character parsing of sources, working with sampled data, and handling parsing results effectively. The object also provides implicit and utility functions to enhance parsing workflows.

The TableParser object provides functionality for parsing tabular data from various sources using a StringTableParser. It includes utilities for character-by-character parsing of sources, working with sampled data, and handling parsing results effectively. The object also provides implicit and utility functions to enhance parsing workflows.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait TableParser[Table] extends TableBuilder[Table]

Type class to parse a set of rows as a Table.

Type class to parse a set of rows as a Table.

Type parameters

Table

the Table type.

Attributes

Companion
object
Supertypes
trait TableBuilder[Table]
class Object
trait Matchable
class Any
Known subtypes
case class TableParserException(msg: String, e: Option[Throwable] = ...) extends Exception

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
abstract class TableParserHelper[X](sourceHasHeaderRow: Boolean = ..., forgiving: Boolean = ...)(using fieldNames: => FieldNames[X]) extends CellParsers

TableParserHelper: abstract class to help with defining an implicit TableParser of Table[X]. Note that this class extends CellParser[X]. It is expected that this should be sub-classed by the object which is the companion object of X. That will make it easiest for the compiler to discover the implicit value of type TableParser of Table[X]

TableParserHelper: abstract class to help with defining an implicit TableParser of Table[X]. Note that this class extends CellParser[X]. It is expected that this should be sub-classed by the object which is the companion object of X. That will make it easiest for the compiler to discover the implicit value of type TableParser of Table[X]

NOTE: this class should be used for simple cases where the the data and type X match according to one of options for sourceHasHeaderRow. More complex situations can easily be handled but not using this TableParserHelper class.

Type parameters

X

the type for which we require a TableParser[X].

Value parameters

forgiving

true if individual rows of the source which do not parse successfully, are logged but otherwise do not affect the success of the overall parsing.

sourceHasHeaderRow

true (default) if the data to be read has an explicit header row with column names that match the parameters of type X; false if there is no header row in the data AND if the data has (unnamed) columns of the same number and in the same order as defined by type X.

Attributes

Supertypes
trait CellParsers
class Object
trait Matchable
class Any

Types

type StringList = List[String]

type alias for the results of parsing repetitions of String.

type alias for the results of parsing repetitions of String.

Attributes

type Strings = Seq[String]

type alias for parsing rows which are composed of a sequence of String.

type alias for parsing rows which are composed of a sequence of String.

Attributes

Value members

Concrete methods

def cellReader[T](using cellParser: CellParser[T]): CellParser[T]