Package com.saxonica.functions.qt4.csv
Class CsvParser
java.lang.Object
com.saxonica.functions.qt4.csv.CsvParser
Parser for CSV files, used by functions csv-to-arrays, parse-csv, and csv-to-xml.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCodepoint iterator that provides the following services: (a) reading ahead, making the current and next codepoints available to the caller; (b) normalizing CR and CRLF line endings to a single LF:; (c) maintaining line number and column number. -
Constructor Summary
ConstructorsConstructorDescriptionCsvParser(StringValue input, Map<String, GroundedValue> csvOptions, CsvContentHandler handler) Create a new CSV parser -
Method Summary
Modifier and TypeMethodDescriptionstatic SequenceIteratorparse(StringValue input, Map<String, GroundedValue> csvOptions) Parse an input string containing CSV data into a sequence of ArrayItems (the rows) containing StringValues (the fields), controlled by the passed-in csvOptions.static SequenceIteratorparse(StringValue input, Map<String, GroundedValue> csvOptions, CsvContentHandler handler) Parse an input string containing CSV data into a sequence of ArrayItems (the rows) containing StringValues (the fields), controlled by the passed-in csvOptions.Parse the input into a sequence of arrays and return them
-
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 XPathExceptionParse 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 aCsvContentHandlerusing 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 XPathExceptionParse 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 existingCsvContentHandlerto 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
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
-