CsvReader

zio.blocks.schema.csv.CsvReader
object CsvReader

CSV row parsing utility using a state machine approach with proper error reporting.

Provides methods to parse individual rows, headers, and complete CSV documents. Parsing follows RFC 4180 rules:

  • Unquoted fields end at delimiters, newlines, or EOF
  • Quoted fields preserve delimiters and newlines as literal content
  • Quote characters within quoted fields are escaped by doubling them
  • Handles CR, LF, and CRLF line endings uniformly

Attributes

Source
CsvReader.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
CsvReader.type

Members list

Value members

Concrete methods

def readAll(input: String, config: CsvConfig): Either[CsvError, (IndexedSeq[String], IndexedSeq[IndexedSeq[String]])]

Parses a complete CSV document including header and all data rows.

Parses a complete CSV document including header and all data rows.

Value parameters

config

the CSV configuration

input

the full CSV input string

Attributes

Returns

Right((header, dataRows)) on success where header contains column names (empty if config.hasHeader is false) and dataRows contains all data rows, or Left(CsvError.ParseError(...)) on malformed input

Source
CsvReader.scala
def readHeader(input: String, config: CsvConfig): Either[CsvError, (IndexedSeq[String], Int)]

Parses just the header row (first row) from the CSV input.

Parses just the header row (first row) from the CSV input.

Value parameters

config

the CSV configuration

input

the full CSV input string

Attributes

Returns

Right((headerFields, offset)) on success, or Left(CsvError.ParseError(...)) on malformed input

Source
CsvReader.scala
def readRow(input: String, offset: Int, config: CsvConfig): Either[CsvError, (IndexedSeq[String], Int)]

Parses a single CSV row starting at the given offset.

Parses a single CSV row starting at the given offset.

Value parameters

config

the CSV configuration controlling delimiter and quoting

input

the full CSV input string

offset

the character position to start parsing from

Attributes

Returns

Right((fields, newOffset)) on success where fields contains the parsed field values and newOffset is the position after the consumed row, or Left(CsvError.ParseError(...)) on malformed input

Source
CsvReader.scala