Class CsvParser

java.lang.Object
com.saxonica.functions.qt4.csv.CsvParser

public class CsvParser extends Object
Parser for CSV files, used by functions csv-to-arrays, parse-csv, and csv-to-xml.
  • Constructor Details

    • CsvParser

      public CsvParser(StringValue input, Map<String,GroundedValue> csvOptions, CsvContentHandler handler)
      Create a new CSV parser
      Parameters:
      input - the input CSV data.
      csvOptions - parsing options.
      handler - the content handler to receive parsing events.
  • Method Details

    • parse

      public static SequenceIterator parse(StringValue input, Map<String,GroundedValue> csvOptions) throws XPathException
      Parse an input string containing CSV data into a sequence of ArrayItems (the rows) containing StringValues (the fields), controlled by the passed-in csvOptions. This form constructs a CsvContentHandler using the passed-in csvOptions.
      Parameters:
      input - the CSV data.
      csvOptions - the processed options specified by the caller.
      Returns:
      the CSV data represented as a sequence of arrays (array(xs:string)*).
      Throws:
      XPathException - if parsing fails
    • parse

      public static SequenceIterator parse(StringValue input, Map<String,GroundedValue> csvOptions, CsvContentHandler handler) throws XPathException
      Parse an input string containing CSV data into a sequence of ArrayItems (the rows) containing StringValues (the fields), controlled by the passed-in csvOptions. This form requires an existing CsvContentHandler to be used.
      Parameters:
      input - the CSV data.
      csvOptions - the processed options specified by the caller.
      handler - the content handler to receive CSV parsing events.
      Returns:
      the CSV data represents as a sequence of arrays (array(xs:string)*).
      Throws:
      XPathException - if parsing fails
    • parseInput

      public SequenceIterator parseInput() throws XPathException
      Parse the input into a sequence of arrays and return them
      Returns:
      the parsed input as an array(xs:string)*
      Throws:
      XPathException - if parsing fails