Table

com.phasmidsoftware.tableparser.core.table.Table
See theTable companion trait
object Table

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Table.type

Members list

Value members

Concrete methods

def apply[X](xs: Iterable[X], maybeHeader: Option[Header]): Table[X]

Method to construct one of the standard table types, given an Iterable of T and an optional header.

Method to construct one of the standard table types, given an Iterable of T and an optional header.

Type parameters

X

the underlying type of xs.

Value parameters

maybeHeader

an optional Header.

xs

an Iterable of X.

Attributes

Returns

a Table[X] which is either a HeadedTable or an UnheadedTable, as appropriate.

def parse[T : TableParser](ws: Iterator[String]): Try[T]

Primary method to parse a table from an Iterator of String. This method is, in turn, invoked by all other parse methods defined below (other than parseSequence).

Primary method to parse a table from an Iterator of String. This method is, in turn, invoked by all other parse methods defined below (other than parseSequence).

Type parameters

T

the type of the resulting table.

Value parameters

ws

the Strings.

Attributes

Returns

an Try[T]

def parse[T : TableParser](ws: Iterable[String]): Try[T]

Method to parse a table from an Iterable of String.

Method to parse a table from an Iterable of String.

Type parameters

T

the type of the resulting table.

Value parameters

ws

the Strings.

Attributes

Returns

an Try[T]

def parse[T : TableParser](sy: => Try[Source]): Try[T]

Method to parse a table from a Source (with proper resource management of the source).

Method to parse a table from a Source (with proper resource management of the source).

Type parameters

T

the type of the resulting table.

Value parameters

sy

the Source.

Attributes

Returns

an Try[T]

def parse[T](u: => URI)(using evidence$1: TableParser[T], codec: Codec): Try[T]

Method to parse a table from a URI with an implicit encoding. If the URI has a fragment identifier which selects rows (RFC 7111, e.g. "data.csv#row=5-7": see CsvFragment), only those rows are in the table (its header lines are rows 1, etc.). Up to 2.0.3, a URI with a fragment could not be parsed at all.

Method to parse a table from a URI with an implicit encoding. If the URI has a fragment identifier which selects rows (RFC 7111, e.g. "data.csv#row=5-7": see CsvFragment), only those rows are in the table (its header lines are rows 1, etc.). Up to 2.0.3, a URI with a fragment could not be parsed at all.

Type parameters

T

the type of the resulting table.

Value parameters

codec

(implicit) the encoding.

u

the URI.

Attributes

Returns

an Try[T]

def parse[T : TableParser](u: => URI, enc: String): Try[T]

Method to parse a table from a URI with an explicit encoding.

Method to parse a table from a URI with an explicit encoding.

Type parameters

T

the type of the resulting table.

Value parameters

enc

the encoding.

u

the URI.

Attributes

Returns

an Try[T]

def parseFile[T](path: Path)(using evidence$1: TableParser[T], codec: Codec): Try[T]

Parses a file at the given path into an instance of type T using the provided implicit TableParser.

Parses a file at the given path into an instance of type T using the provided implicit TableParser.

Type parameters

T

The type to which the file content will be parsed.

Value parameters

codec

The character codec to be used for reading the file. It is provided implicitly.

path

The path to the file that needs to be parsed.

Attributes

Returns

A Try containing the parsed instance of type T if successful, or a Failure if an error occurs.

def parseFile[T : TableParser](path: Path, enc: String): Try[T]

Parses a file located at the specified path using the provided encoding and a typeclass instance for parsing the file content into the desired type.

Parses a file located at the specified path using the provided encoding and a typeclass instance for parsing the file content into the desired type.

Type parameters

T

The type to which the file content will be parsed, requiring an implicit TableParser instance.

Value parameters

enc

The encoding used to read the file.

path

The path to the file that needs to be parsed.

Attributes

Returns

A Try containing the parsed result of type T if successful, or a failure if an error occurs during parsing.

def parseFileRaw(pathname: String, predicate: Try[RawRow] => Boolean)(using codec: Codec): Try[Table[RawRow]]

Method to parse a table from a File as a table of Seq[String].

Method to parse a table from a File as a table of Seq[String].

Value parameters

codec

(implicit) the encoding.

pathname

the path name.

Attributes

Returns

an Try of Table[RawRow] where RawRow is a Seq[String].

def parseInputStream[T](i: => InputStream)(using evidence$1: TableParser[T], codec: Codec): Try[T]

Method to parse a table from an InputStream with an implicit encoding.

Method to parse a table from an InputStream with an implicit encoding.

Type parameters

T

the type of the resulting table.

Value parameters

codec

(implicit) the encoding.

i

the InputStream (call-by-name).

Attributes

Returns

an Try[T]

def parseInputStream[T : TableParser](si: Try[InputStream], enc: String): Try[T]

Method to parse a table from an InputStream with an explicit encoding.

Method to parse a table from an InputStream with an explicit encoding.

Type parameters

T

the type of the resulting table.

Value parameters

enc

the encoding.

si

the InputStream, wrapped in Try.

Attributes

Returns

an Try[T]

def parsePathRaw(path: Path, predicate: Try[RawRow] => Boolean, maybeFixedHeader: Option[Header] = ..., forgiving: Boolean = ...)(using codec: Codec): Try[Table[RawRow]]

Parses a file at the given path into a Table[RawRow] using the specified conditions and options.

Parses a file at the given path into a Table[RawRow] using the specified conditions and options.

Value parameters

codec

the character encoding to be used for reading the file

forgiving

a flag indicating whether parsing should continue with warnings or fail on errors

maybeFixedHeader

an optional header to be used instead of inferring it from the file

path

the file path to be parsed

predicate

a filtering function applied to each RawRow wrapped in a Try, determining whether the row is included

Attributes

Returns

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

def parseRaw(ws: Iterable[String], predicate: Try[RawRow] => Boolean = ..., maybeFixedHeader: Option[Header] = ..., forgiving: Boolean = ..., multiline: Boolean = ...): Try[RawTable]

Method to parse a table of raw rows from an Iterable of String.

Method to parse a table of raw rows from an Iterable of String.

Value parameters

ws

the Strings.

Attributes

Returns

an Try of Table of RawRow

def parseResource[T](w: String, clazz: Class[_] = ...)(using evidence$1: TableParser[T], codec: Codec): Try[T]

Method to parse a table from a resource.

Method to parse a table from a resource.

Type parameters

T

the type of the resulting table.

Value parameters

clazz

the class for which the resource should be sought (should default to the calling class but doesn't).

codec

(implicit) the encoding.

w

the resource name.

Attributes

Returns

an Try[T]

def parseResource[T](u: => URL)(using evidence$1: TableParser[T], codec: Codec): Try[T]

Method to parse a table from a URL.

Method to parse a table from a URL.

Type parameters

T

the type of the resulting table.

Value parameters

u

the URI.

Attributes

Returns

an Try[T]

def parseResource[T : TableParser](u: => URL, enc: String): Try[T]

Method to parse a table from a URL with an explicit encoding.

Method to parse a table from a URL with an explicit encoding.

NOTE: the logic here is different from that of parseResource(u:=>URL)(using codec: Codec) above.

Type parameters

T

the type of the resulting table.

Value parameters

enc

the encoding.

u

the URL.

Attributes

Returns

an Try[T]

def parseResourceRaw(s: String, predicate: Try[RawRow] => Boolean = ..., maybeFixedHeader: Option[Header] = ..., forgiving: Boolean = ..., clazz: Class[_] = ...)(using codec: Codec): Try[Table[RawRow]]

Method to parse a table from a resource as a table of Seq[String].

Method to parse a table from a resource as a table of Seq[String].

Value parameters

clazz

the class for which the resource should be sought (defaults to the calling class).

codec

(implicit) the encoding.

forgiving

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

maybeFixedHeader

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

s

the resource name.

Attributes

Returns

an Try of Table[RawRow] where RawRow is a Seq[String].

def parseSequence[T : TableParser](wss: Iterator[Seq[String]]): Try[T]

Method to parse a table from a Seq of Seq of String.

Method to parse a table from a Seq of Seq of String.

Type parameters

T

the type of the resulting table.

Value parameters

wss

the Sequence of Strings.

Attributes

Returns

an Try[T]

def parseSource[T : TableParser](x: => Source): Try[T]

Method to parse a table from a Source.

Method to parse a table from a Source.

NOTE: the caller is responsible for closing the given Source.

Type parameters

T

the type of the resulting table.

Value parameters

x

the Source.

Attributes

Returns

an Try[T]

def sourceFromClassResource(w: String, clazz: Class[_])(using codec: Codec): Try[Source]

Method to open a source defined by a Class and a resource name.

Method to open a source defined by a Class and a resource name.

Value parameters

clazz

the class.

w

the resource name.

Attributes

Returns

an Try[Source].

def sourceFromFilename(filename: => String)(using codec: Codec): Try[Source]

Method to open source defined by a File.

Method to open source defined by a File.

Value parameters

filename

a File.

Attributes

Returns

an Try[Source].

def toCSVRow(t: Table[Row])(using csvAttributes: CsvAttributes): Try[String]

Method to render the given Table[Row] as a CSV String with header.

Method to render the given Table[Row] as a CSV String with header.

Value parameters

csvAttributes

implicit value of CsvAttributes.

t

the Table[Row] to be rendered.

Attributes

Returns

an Iterable[String]

def writeCSVFileRow(t: Table[Row], file: File)(using csvAttributes: CsvAttributes): Unit

Method to render the given Table[Row] as a CSV String with header.

Method to render the given Table[Row] as a CSV String with header.

Value parameters

csvAttributes

implicit value of CsvAttributes.

file

the destination File for the rendering of t.

t

the Table[Row] to be rendered.

Attributes

Returns

an Iterable[String]