package parse
- Alphabetic
- By Inheritance
- parse
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- 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
RowProcessortype class and provides additional methods for processing iterators of input rows based on headers and transformation functions. It relies on the implicit evidence of theJoinabletype class to define behavior for handling the input type.- Row
the type of rows output by this processor.
- abstract class AbstractTableParser[Table] extends TableParser[Table]
Abstract base class for implementations of TableParser[T].
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
- Table
the (parametric) Table type.
- case class AttributeSet(xs: StringList) extends Product with Serializable
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 "{}".
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).
- xs
the attribute values.
- case class BlankException(e: Throwable = null) extends ParseableException with Product with Serializable
A case class representing a specific exception type
BlankExceptionused when a blank value or an error associated with a blank value is encountered during the parsing process.A case class representing a specific exception type
BlankExceptionused when a blank value or an error associated with a blank value is encountered during the parsing process. It extendsParseableExceptionas its base type.- e
an optional
Throwablecause associated with the exception. Defaults tonullif not provided.
// Throwing a BlankException with a cause throw BlankException(new IllegalArgumentException("Blank value encountered")) // Throwing a BlankException without a cause throw BlankException()
Example: - trait CellParser[+T] extends StringConverter[T]
Type-class trait CellParser[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.
- T
the (covariant) type of the resulting object.
- Annotations
- @implicitNotFound()
- trait CellParsers extends AnyRef
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.
- case class CellValue(w: String) extends Convertible with Product with Serializable
A concrete Convertible corresponding to a cell value.
A concrete Convertible corresponding to a cell value.
- w
the String contained by a cell.
- trait ColumnHelper[T] extends AnyRef
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.
- T
the type of the object being helped.
- Annotations
- @implicitNotFound()
- sealed trait Convertible extends AnyRef
Trait Convertible.
- trait CopyableTableParser[Row, Input, Table] extends AnyRef
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
CopyableTableParserprovides 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; andTable, representing the parsed table as a whole.- Row
the type of a single row in the table.
- Input
the type of the raw input data used to parse rows.
- Table
the type of the parsed table.
- trait DefaultRowConfig extends RowConfig
Default RowConfig trait.
Default RowConfig trait.
TODO Issue #48. Need method for default RowConfig. The problem with the current version is that, if the delimiter is changed, the string regex must change too.
- abstract class HeadedCSVTableParser[T] extends StringTableParser[Table[T]]
Abstract class for parsing tables from CSV-formatted strings, where the table has a defined header.
Abstract class for parsing tables from CSV-formatted strings, where the table has a defined header. This is the most convenient subtype of
TableParserfor most CSV files.- T
the parametric type of rows in the table.
- abstract class HeadedStringTableParser[X] extends StringTableParser[Table[X]] with CopyableTableParser[X, String, Table[X]]
Abstract class to define a StringTableParser that assumes a header to be found in the input file.
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
- X
the underlying row type for which there must be evidence of a CellParser and ClassTag.
- See also
HeadedStringTableParser#create
- class IndexedInputToRowsAggregator[Input, Row] extends InputAggregator[Input, Row, Try]
The
IndexedInputToRowsAggregatorclass provides functionality to process and aggregate input data of typeInputinto structured rows of typeRow, with support for error handling, validation, and conditional processing.The
IndexedInputToRowsAggregatorclass provides functionality to process and aggregate input data of typeInputinto structured rows of typeRow, with support for error handling, validation, and conditional processing. It extends the abstract classInputAggregator.The class leverages implicit
Joinablebehavior forInputand works withTryto 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.- Input
the type of input elements to be processed.
- Row
the type of rows transformed from the input.
- class IndexedInputToRowsTransformer[Input, Row] 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
InputTransformerand provides functionality to apply a transformation defined by a functionfto indexed inputs ((Input, Int)), processing the resultingTry[Row]instances to either extract validRowresults or handle errors using logging.- Input
The type of input elements to be processed. Must have an implicit
Joinable[Input]defined.- Row
The type of rows produced after transformation.
- abstract class InputAggregator[Input, Row, Wrapper[_]] extends InputPreprocessor[Input, Row]
The
InputAggregatorabstract class extends theInputPreprocessortrait to provide additional higher-level processing functionality for input data.The
InputAggregatorabstract class extends theInputPreprocessortrait to provide additional higher-level processing functionality for input data. It focuses on aggregating and processing transformed rows encapsulated inTry, with support for filtering invalid or failed transformations and wrapping the successfully processed rows in a desired container typeWrapper[_].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.
- 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, orList.
- trait InputMapper[Input, Row] extends (Input) => Try[Row]
A trait that defines a contract for mapping an input of type
Inputto a row of typeRowas a computation that can either succeed or fail, represented byTry[Row].A trait that defines a contract for mapping an input of type
Inputto a row of typeRowas a computation that can either succeed or fail, represented byTry[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
InputPreprocessorinstead.- 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).
- trait InputPreprocessor[Input, Row] extends AnyRef
A trait for preprocessing input data elements into rows, representing an early stage in data transformation pipelines.
A trait for preprocessing input data elements into rows, representing an early stage in data transformation pipelines. The
InputPreprocessortrait defines a contract for mapping input data of typeInputinto rows of typeRow, encapsulated inTryto 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.
- 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).
- abstract class InputTransformer[Input, Row] extends InputPreprocessor[Input, Row]
An abstract class
InputTransformerthat extendsInputPreprocessorand defines methods for transforming input data into rows, including error handling and extracting valid data rows.An abstract class
InputTransformerthat extendsInputPreprocessorand 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.- 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.
- case class InvalidParseException(msg: String, e: Throwable = null) extends ParseableException with Product with Serializable
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.- msg
A string message providing details about the parsing error.
- e
An optional
Throwablecause for the exception (default isnull).
- class LineParser extends JavaTokenParsers
LineParser: class to parse lines of a CSV file.
LineParser: class to parse lines of a CSV file. NOTE: list elements always appear as a string in the form { element0 , element1 , ... }
- trait MultiCellParser[T] extends CellParser[T]
CONSIDER renaming this to something like RowParser, or RawRowParser.
CONSIDER renaming this to something like RowParser, or RawRowParser.
- T
the type of the result.
- case class MultiLineException[X](x: X) extends Exception with Product with Serializable
The
MultiLineExceptionclass is a case class that extends theExceptionclass.The
MultiLineExceptionclass is a case class that extends theExceptionclass. This exception is designed to handle multi-line exception scenarios where custom content is provided to describe the error.- 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
- x
The content of type
Xthat describes the exception or provides context for it.
- case class ParseLogicException(msg: String, e: Throwable = null) extends Exception with Product with Serializable
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.
- msg
A descriptive message providing information about the error. This message is used to help diagnose the cause of the parsing failure.
- e
The underlying cause of the exception, if any. Defaults to
nullif no specific cause is provided.
- trait Parseable[T] extends AnyRef
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.
- T
the resulting type.
- Annotations
- @implicitNotFound()
- abstract class ParseableException extends Exception
Abstract class
ParseableExceptionis an extension of the standard ScalaExceptionclass and provides a base structure for defining custom exceptions that can carry a parse error message and an optional cause (aThrowable).Abstract class
ParseableExceptionis an extension of the standard ScalaExceptionclass and provides a base structure for defining custom exceptions that can carry a parse error message and an optional cause (aThrowable).This class can be used as a foundation for defining exceptions when parsing operations fail or encounter errors, allowing informative and structured error reporting.
- abstract class ParseableOption[T] extends Parseable[Option[T]]
Abstract class to parse optional scala values.
Abstract class to parse optional scala values.
- T
the resulting type for which there must be evidence of a Parseable[T].
- case class ParserException(msg: String, e: Throwable = null) extends Exception with Product with Serializable
Represents an exception that occurs during parsing operations.
Represents an exception that occurs during parsing operations.
- msg
the message describing the cause of the exception.
- e
the underlying throwable that caused this exception (optional, defaults to null).
- case class PlainTextHeadedStringTableParser[X](maybeHeader: Option[Header] = None, forgiving: Boolean = false, headerRowsToRead: Int = 1)(implicit evidence$1: CellParser[X], evidence$2: ClassTag[X]) extends HeadedStringTableParser[X] with Product with Serializable
Case class to define a StringTableParser that assumes a header to be found in the input file.
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.
- X
the underlying row type for which there must be evidence of a CellParser and ClassTag.
- 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.
- 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.
- See also
HeadedStringTableParser#create
- abstract class RawParsers extends CellParsers
Abstract class to define a raw parser, that's to say a Parser of Seq[String]
- case class RawTableParser(predicate: (Try[RawRow]) => Boolean = TableParser.includeAll, maybeHeader: Option[Header] = None, forgiving: Boolean = false, multiline: Boolean = false, headerRowsToRead: Int = 1) extends StringTableParser[RawTable] with CopyableTableParser[RawRow, String, RawTable] with Product with Serializable
Class used to parse files as a Table of Seq[String].
Class used to parse files as a Table of Seq[String]. That's to say, no parsing of individual (or groups of) columns.
- predicate
a predicate which, if true, allows inclusion of the input row.
- maybeHeader
an optional fixed header. If None, we expect to find the header defined in the first line of the file.
- forgiving
forcing (defaults to true). If true then an individual malformed row will not prevent subsequent rows being parsed.
- trait RowConfig extends AnyRef
Trait to define the configuration for parsing a row.
- trait RowParser[Row, Input] extends AnyRef
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.
- Row
the (parametric) Row type for which there must be evidence of a RowParser[Row, Input].
- Input
the (parametric) Input type for which there must be evidence of a RowParser[Row, Input].
- Annotations
- @implicitNotFound()
- trait RowProcessor[Row] extends AnyRef
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.
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.- Row
the type that each row will be processed into.
- Annotations
- @implicitNotFound()
- case class RowProcessorException(msg: String, e: Option[Throwable] = None) extends Exception with Product with Serializable
- case class RowValues(row: Row, header: Header) extends Convertible with Product with Serializable
A concrete Convertible corresponding to a row.
A concrete Convertible corresponding to a row.
- row
the Row containing several values.
- header
the Header.
- trait SingleCellParser[T] extends CellParser[T]
Trait SingleCellParser, which extends CellParser[T].
Trait SingleCellParser, which extends CellParser[T].
- T
the type of the resulting object.
- case class StandardRowParser[Row](parser: LineParser)(implicit evidence$1: CellParser[Row]) extends StringParser[Row] with Product with Serializable
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.
- Row
the (parametric) Row type for which there must be evidence of a CellParser[Row].
- parser
the LineParser to use
- case class StandardStringsParser[Row]()(implicit evidence$3: CellParser[Row]) extends StringsParser[Row] with Product with Serializable
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.
- Row
the (parametric) Row type for which there must be evidence of a CellParser[Row].
- trait StringConverter[+T] extends AnyRef
- type StringList = List[String]
type alias for the results of parsing repetitions of String.
- trait StringParser[Row] extends RowParser[Row, String]
A RowParser whose input type is String.
A RowParser whose input type is String.
- Row
the (parametric) Row type for which there must be evidence of a RowParser[Row, Input].
- abstract class StringRowProcessor[Row] extends AbstractRowProcessor[Row]
Abstract class to extend AbstractTableParser but with Input = String.
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.
- Row
the row type.
- abstract class StringTableParser[Table] extends AbstractTableParser[Table]
Abstract class to extend AbstractTableParser but with Input = String.
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.
- Table
the table type.
- type Strings = Seq[String]
type alias for parsing rows which are composed of a sequence of String.
- 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.
- Row
the (parametric) Row type for which there must be evidence of a CellParser[Row].
- 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.
- Table
the table type.
- trait TableBuilder[Table] extends AnyRef
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.
- Table
the table type to be built.
- 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.
- Table
the Table type.
- Annotations
- @implicitNotFound()
- case class TableParserException(msg: String, e: Option[Throwable] = None) extends Exception with Product with Serializable
- abstract class TableParserHelper[X] extends CellParsers
TableParserHelper: abstract class to help with defining an implicit 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.
- X
the type for which we require a TableParser[X].
Value Members
- def cellReader[T](implicit cellParser: CellParser[T]): CellParser[T]
- object AbstractTableParser
The
AbstractTableParsercompanion object provides utility methods for logging exceptions during the table parsing process.The
AbstractTableParsercompanion 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
Throwableor wrapped inside aTryresult. - object AttributeSet extends CellParsers with CsvGenerators with CsvRenderers with Serializable
The
AttributeSetobject provides utility methods for constructing and parsing instances of theAttributeSetclass.The
AttributeSetobject provides utility methods for constructing and parsing instances of theAttributeSetclass. 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. - object CellParser
- object ColumnHelper
Object containing utility functions for mapping and transforming column names, providing multiple default strategies for common transformations.
- object HeadedStringTableParser
- object LineParser
Companion object for the
LineParserclass, responsible for constructing instances ofLineParserand providing logging capabilities. - object ListParser extends JavaTokenParsers
This object is a parser of lists.
This object is a parser of lists. A list is considered to be enclosed by {} and separated by commas.
- object Parseable
The
Parseableobject provides a set of predefinedParseabletype class instances that enable parsing ofStringrepresentations into instances of various data types.The
Parseableobject provides a set of predefinedParseabletype class instances that enable parsing ofStringrepresentations into instances of various data types. These parsers operate based on theParseable[T]trait, which defines aparsemethod that returns aTry[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
Failureinstance with an appropriate exception message when parsing fails. - object ParseableOption
The
ParseableOptionobject provides implicit instances ofParseableOptionfor various types, enabling the parsing of optional Scala values.The
ParseableOptionobject provides implicit instances ofParseableOptionfor various types, enabling the parsing of optional Scala values.ParseableOptionworks in conjunction with the abstract class of the same name, allowing strings to be parsed into optional values of specified types while handling blanks asNone. This is achieved through the underlyingParseableevidence 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]] = implicitly[Parseable[Option[Int]]].parse("42", None) val maybeNone: Try[Option[Int]] = implicitly[Parseable[Option[Int]]].parse("", None)
The implicit instances provided: -
ParseableOptionString: Parses optionalString-ParseableOptionBoolean: Parses optionalBoolean-ParseableOptionByte: Parses optionalByte-ParseableOptionShort: Parses optionalShort-ParseableOptionInt: Parses optionalInt-ParseableOptionFloat: Parses optionalFloat-ParseableOptionDouble: Parses optionalDouble-ParseableOptionLong: Parses optionalLong-ParseableOptionBigInt: Parses optionalBigInt-ParseableOptionBigDecimal: Parses optionalBigDecimal-ParseableOptionLocalDate: Parses optionalLocalDate-ParseableOptionURL: Parses optionaljava.net.URL-ParseableOptionFile: Parses optionaljava.io.File - object RawParsers
Object
RawParsersprovides utility instances for parsing raw data represented as sequences of strings.Object
RawParsersprovides 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.
- object RowConfig
Companion object to RowConfig.
- object RowValues extends Serializable
- object StandardRowParser extends Serializable
- object StdCellParsers extends CellParsers
TODO resolve the naming issue here.
- object StringConverter
- object TableParser
The
TableParserobject provides functionality for parsing tabular data from various sources using aStringTableParser.The
TableParserobject provides functionality for parsing tabular data from various sources using aStringTableParser. 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.