CsvParser)
In addition to the configuration options provided by CommonParserSettings, the CSVParserSettings include:
When reading, if the parser does not read any character from the input, and the input is within quotes, the empty is used instead of an empty string
com.univocity.parsers.csv.CsvParser , com.univocity.parsers.csv.CsvFormat , com.univocity.parsers.common.CommonParserSettings
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private char[] | |
| private String | |
| private boolean | |
| private int | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private UnescapedQuoteHandling |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public final CsvParserSettings | clone()
Overrides com. |
| public final CsvParserSettings | clone(boolean
flag indicating whether to clear settings that are likely to be associated with a given input. clearInputSpecificSettings)Overrides com. |
| protected CsvFormat | Returns: and instance of CsvFormat configured to handle CSV inputs compliant to the RFC4180 standard.Implements abstract com. |
| public final void | detectFormatAutomatically()
Convenience method to turn on all format detection features in a single method call, namely: |
| public final void | detectFormatAutomatically(char...
possible delimiters for detection, in order of priority. delimitersForDetection)Convenience method to turn on all format detection features in a single method call, namely: |
| public final char[] | Returns: the possible delimiter characters, in order of priority.Returns the sequence of possible delimiters for detection when |
| public String | Returns: the String representation of an empty valueReturns the String representation of an empty value (defaults to null) When reading, if the parser does not read any character from the input, and the input is within quotes, the empty is used instead of an empty string |
| public int | Returns: the number of sample rows used in the CSV format auto-detection processReturns the number of sample rows used in the CSV format auto-detection process (defaults to 20) |
| public boolean | Returns: true if leading whitespaces from quoted values should be skipped, false otherwiseReturns whether or not leading whitespaces from quoted values should be skipped (defaults to false)
Note: if |
| public boolean | Returns: true if trailing whitespaces from quoted values should be skipped, false otherwiseReturns whether or not trailing whitespaces from within quoted values should be skipped (defaults to false)
Note: if |
| public boolean | Returns: a flag indicating whether enclosing quotes should be maintained when parsing quoted values.Flag indicating whether the parser should keep enclosing quote characters in the values parsed from the input. |
| public UnescapedQuoteHandling | Returns: the handling method to be used when unescaped quotes are found in the input, ornull if not set.Returns the method of handling values with unescaped quotes. |
| public final boolean | Returns: a flag indicating whether the parser should analyze the input to discover the column delimiter character.Returns a flag indicating whether the parser should analyze the input to discover the column delimiter character. |
| public boolean | Returns: true if escape sequences should be processed in unquoted values, otherwise falseIndicates whether escape sequences should be processed in unquoted values. |
| public final boolean | Returns: a flag indicating whether escape sequences should be kept (and not replaced) by the parser.Indicates whether the parser should keep any escape sequences if they are present in the input (i.e. a quote escape sequence such as two double quotes
|
| public boolean | Returns: true if line separators in quoted values will be normalized, false otherwiseFlag indicating whether the parser should replace line separators, specified in |
| public boolean | Returns: a flag indicating whether or not the CSV parser should accept unescaped quotes inside quoted values.
Deprecated
use
Indicates whether the CSV parser should accept unescaped quotes inside quoted values and parse them normally.
getUnescapedQuoteHandling() instead.
|
| public boolean | Returns: a flag indicating that the parser should stop accumulating values when a field delimiter character is found when parsing unquoted and unescaped values.
Deprecated
use
When parsing unescaped quotes, indicates the parser should stop accumulating characters and consider the value parsed when a delimiter is found.
getUnescapedQuoteHandling() instead.
|
| public final boolean | Returns: a flag indicating whether the parser should analyze the input to discover the quote character. The quote escape will also be detected as part of this process.Returns a flag indicating whether the parser should analyze the input to discover the quote character. |
| protected CharAppender | Returns: an instance of CharAppender with the configured limit of maximum characters per column and the default value used to represent an empty value (when the String parsed from the input, within quotes, is empty)Overrides com. This overrides the parent's version because the CSV parser does not rely on the appender to identify null values, but on the other hand, the appender is required to identify empty values. |
| public final void | setDelimiterDetectionEnabled(boolean
the flag to enable/disable discovery of the column delimiter character.
to separatorDetectionEnabled)true, in order of priority.Configures the parser to analyze the input before parsing to discover the column delimiter character. |
| public final void | setDelimiterDetectionEnabled(boolean
the flag to enable/disable discovery of the column delimiter character. separatorDetectionEnabled, char... possible delimiters for detection when delimitersForDetection)isDelimiterDetectionEnabled() evaluates
to true, in order of priority.Configures the parser to analyze the input before parsing to discover the column delimiter character. |
| public void | setEmptyValue(String
the String representation of an empty value emptyValue)Sets the String representation of an empty value (defaults to null) When reading, if the parser does not read any character from the input, and the input is within quotes, the empty is used instead of an empty string |
| public void | setEscapeUnquotedValues(boolean
a flag indicating whether escape sequences should be processed in unquoted values escapeUnquotedValues)Configures the parser to process escape sequences in unquoted values. |
| public void | setFormatDetectorRowSampleCount(int
the number of sample rows used in the CSV format auto-detection process formatDetectorRowSampleCount)Updates the number of sample rows used in the CSV format auto-detection process (defaults to 20) |
| public void | setIgnoreLeadingWhitespacesInQuotes(boolean
whether leading whitespaces from quoted values should be skipped ignoreLeadingWhitespacesInQuotes)Defines whether or not leading whitespaces from quoted values should be skipped (defaults to false)
Note: if |
| public void | setIgnoreTrailingWhitespacesInQuotes(boolean
whether trailing whitespaces from quoted values should be skipped ignoreTrailingWhitespacesInQuotes)Defines whether or not trailing whitespaces from quoted values should be skipped (defaults to false)
Note: if |
| public final void | setKeepEscapeSequences(boolean
the flag indicating whether escape sequences should be kept (and not replaced) by the parser. keepEscapeSequences)Configures the parser to keep any escape sequences if they are present in the input (i.e. a quote escape sequence such as 2 double quotes |
| public void | setKeepQuotes(boolean
flag indicating whether enclosing quotes should be maintained when parsing quoted values. keepQuotes)Configures the parser to keep enclosing quote characters in the values parsed from the input. |
| public void | setNormalizeLineEndingsWithinQuotes(boolean
flag indicating whether line separators in quoted values should be replaced by
the the character specified in normalizeLineEndingsWithinQuotes)Format#getNormalizedNewline() .Configures the parser to replace line separators, specified in |
| public void | setParseUnescapedQuotes(boolean
indicates whether or not the CSV parser should accept unescaped quotes inside quoted values. parseUnescapedQuotes)
Deprecated
use
Configures how to handle unescaped quotes inside quoted values.
setUnescapedQuoteHandling(UnescapedQuoteHandling) instead.
|
| public void | setParseUnescapedQuotesUntilDelimiter(boolean
a flag indicating that the parser should stop accumulating values when a field delimiter character is
found when parsing unquoted and unescaped values. parseUnescapedQuotesUntilDelimiter)
Deprecated
use
Configures the parser to process values with unescaped quotes, and stop accumulating characters and consider the value parsed when a delimiter is found.
setUnescapedQuoteHandling(UnescapedQuoteHandling) instead.
|
| public final void | setQuoteDetectionEnabled(boolean
the flag to enable/disable discovery of the quote character. The quote escape will also be detected as part of this process. quoteDetectionEnabled)Configures the parser to analyze the input before parsing to discover the quote character. |
| public void | setUnescapedQuoteHandling(UnescapedQuoteHandling
the handling method to be used when unescaped quotes are found in the input. unescapedQuoteHandling)Configures the handling of values with unescaped quotes. |
| public final void | trimQuotedValues(boolean
a flag indicating whether whitespaces around values extracted from a quoted field should be removed trim)Configures the parser to trim any whitespaces around values extracted from within quotes. |
| delimiterDetectionEnabled | back to summary |
|---|---|
| private boolean delimiterDetectionEnabled | |
| delimitersForDetection | back to summary |
|---|---|
| private char[] delimitersForDetection | |
| emptyValue | back to summary |
|---|---|
| private String emptyValue | |
| escapeUnquotedValues | back to summary |
|---|---|
| private boolean escapeUnquotedValues | |
| formatDetectorRowSampleCount | back to summary |
|---|---|
| private int formatDetectorRowSampleCount | |
| ignoreLeadingWhitespacesInQuotes | back to summary |
|---|---|
| private boolean ignoreLeadingWhitespacesInQuotes | |
| ignoreTrailingWhitespacesInQuotes | back to summary |
|---|---|
| private boolean ignoreTrailingWhitespacesInQuotes | |
| keepEscapeSequences | back to summary |
|---|---|
| private boolean keepEscapeSequences | |
| keepQuotes | back to summary |
|---|---|
| private boolean keepQuotes | |
| normalizeLineEndingsWithinQuotes | back to summary |
|---|---|
| private boolean normalizeLineEndingsWithinQuotes | |
| parseUnescapedQuotes | back to summary |
|---|---|
| private boolean parseUnescapedQuotes | |
| parseUnescapedQuotesUntilDelimiter | back to summary |
|---|---|
| private boolean parseUnescapedQuotesUntilDelimiter | |
| quoteDetectionEnabled | back to summary |
|---|---|
| private boolean quoteDetectionEnabled | |
| unescapedQuoteHandling | back to summary |
|---|---|
| private UnescapedQuoteHandling unescapedQuoteHandling | |
| CsvParserSettings | back to summary |
|---|---|
| public CsvParserSettings() | |
| addConfiguration | back to summary |
|---|---|
| protected void addConfiguration(Map<String, Object> out) Overrides com.
| |
| clone | back to summary |
|---|---|
| public final CsvParserSettings clone() Overrides com. Doc from com. Clones this configuration object. Use alternative
| |
| clone | back to summary |
|---|---|
| public final CsvParserSettings clone(boolean clearInputSpecificSettings) Overrides com. Doc from com. Clones this configuration object to reuse user-provided settings.
Properties that are specific to a given input (such as header names and selection of fields) can be reset to their defaults
if the
| |
| createDefaultFormat | back to summary |
|---|---|
| protected CsvFormat createDefaultFormat() Implements abstract com. Returns the default CsvFormat configured to handle CSV inputs compliant to the RFC4180 standard. | |
| detectFormatAutomatically | back to summary |
|---|---|
| public final void detectFormatAutomatically() Convenience method to turn on all format detection features in a single method call, namely: | |
| detectFormatAutomatically | back to summary |
|---|---|
| public final void detectFormatAutomatically(char... delimitersForDetection) Convenience method to turn on all format detection features in a single method call, namely:
| |
| getDelimitersForDetection | back to summary |
|---|---|
| public final char[] getDelimitersForDetection() Returns the sequence of possible delimiters for detection when
| |
| getEmptyValue | back to summary |
|---|---|
| public String getEmptyValue() Returns the String representation of an empty value (defaults to null) When reading, if the parser does not read any character from the input, and the input is within quotes, the empty is used instead of an empty string
| |
| getFormatDetectorRowSampleCount | back to summary |
|---|---|
| public int getFormatDetectorRowSampleCount() Returns the number of sample rows used in the CSV format auto-detection process (defaults to 20)
| |
| getIgnoreLeadingWhitespacesInQuotes | back to summary |
|---|---|
| public boolean getIgnoreLeadingWhitespacesInQuotes() Returns whether or not leading whitespaces from quoted values should be skipped (defaults to false)
Note: if
| |
| getIgnoreTrailingWhitespacesInQuotes | back to summary |
|---|---|
| public boolean getIgnoreTrailingWhitespacesInQuotes() Returns whether or not trailing whitespaces from within quoted values should be skipped (defaults to false)
Note: if
| |
| getKeepQuotes | back to summary |
|---|---|
| public boolean getKeepQuotes() Flag indicating whether the parser should keep enclosing quote characters in the values parsed from the input. Defaults to
| |
| getUnescapedQuoteHandling | back to summary |
|---|---|
| public UnescapedQuoteHandling getUnescapedQuoteHandling() Returns the method of handling values with unescaped quotes.
Defaults to
| |
| isDelimiterDetectionEnabled | back to summary |
|---|---|
| public final boolean isDelimiterDetectionEnabled() Returns a flag indicating whether the parser should analyze the input to discover the column delimiter character. Note that the detection process is not guaranteed to discover the correct column delimiter. In this case the delimiter provided by
| |
| isEscapeUnquotedValues | back to summary |
|---|---|
| public boolean isEscapeUnquotedValues() Indicates whether escape sequences should be processed in unquoted values. Defaults to By default, this is disabled and if the input is
| |
| isKeepEscapeSequences | back to summary |
|---|---|
| public final boolean isKeepEscapeSequences() Indicates whether the parser should keep any escape sequences if they are present in the input (i.e. a quote escape sequence such as two double quotes
This is disabled by default
| |
| isNormalizeLineEndingsWithinQuotes | back to summary |
|---|---|
| public boolean isNormalizeLineEndingsWithinQuotes() Flag indicating whether the parser should replace line separators, specified in
| |
| isParseUnescapedQuotes | back to summary |
|---|---|
| public boolean isParseUnescapedQuotes()
Deprecated use Indicates whether the CSV parser should accept unescaped quotes inside quoted values and parse them normally. Defaults to
| |
| isParseUnescapedQuotesUntilDelimiter | back to summary |
|---|---|
| public boolean isParseUnescapedQuotesUntilDelimiter()
Deprecated use When parsing unescaped quotes, indicates the parser should stop accumulating characters and consider the value parsed when a delimiter is found.
(defaults to
| |
| isQuoteDetectionEnabled | back to summary |
|---|---|
| public final boolean isQuoteDetectionEnabled() Returns a flag indicating whether the parser should analyze the input to discover the quote character. The quote escape will also be detected as part of this process. Note that the detection process is not guaranteed to discover the correct quote & escape.
In this case the characters provided by
| |
| newCharAppender | back to summary |
|---|---|
| protected CharAppender newCharAppender() Overrides com. Returns an instance of CharAppender with the configured limit of maximum characters per column and the default value used to represent an empty value (when the String parsed from the input, within quotes, is empty) This overrides the parent's version because the CSV parser does not rely on the appender to identify null values, but on the other hand, the appender is required to identify empty values.
| |
| setDelimiterDetectionEnabled | back to summary |
|---|---|
| public final void setDelimiterDetectionEnabled(boolean separatorDetectionEnabled) Configures the parser to analyze the input before parsing to discover the column delimiter character. Note that the detection process is not guaranteed to discover the correct column delimiter.
The first character in the list of delimiters allowed for detection will be used, if available, otherwise
the delimiter returned by
| |
| setDelimiterDetectionEnabled | back to summary |
|---|---|
| public final void setDelimiterDetectionEnabled(boolean separatorDetectionEnabled, char... delimitersForDetection) Configures the parser to analyze the input before parsing to discover the column delimiter character. Note that the detection process is not guaranteed to discover the correct column delimiter.
The first character in the list of delimiters allowed for detection will be used, if available, otherwise
the delimiter returned by
| |
| setEmptyValue | back to summary |
|---|---|
| public void setEmptyValue(String emptyValue) Sets the String representation of an empty value (defaults to null) When reading, if the parser does not read any character from the input, and the input is within quotes, the empty is used instead of an empty string
| |
| setEscapeUnquotedValues | back to summary |
|---|---|
| public void setEscapeUnquotedValues(boolean escapeUnquotedValues) Configures the parser to process escape sequences in unquoted values. Defaults to By default, this is disabled and if the input is
| |
| setFormatDetectorRowSampleCount | back to summary |
|---|---|
| public void setFormatDetectorRowSampleCount(int formatDetectorRowSampleCount) Updates the number of sample rows used in the CSV format auto-detection process (defaults to 20)
| |
| setIgnoreLeadingWhitespacesInQuotes | back to summary |
|---|---|
| public void setIgnoreLeadingWhitespacesInQuotes(boolean ignoreLeadingWhitespacesInQuotes) Defines whether or not leading whitespaces from quoted values should be skipped (defaults to false)
Note: if
| |
| setIgnoreTrailingWhitespacesInQuotes | back to summary |
|---|---|
| public void setIgnoreTrailingWhitespacesInQuotes(boolean ignoreTrailingWhitespacesInQuotes) Defines whether or not trailing whitespaces from quoted values should be skipped (defaults to false)
Note: if
| |
| setKeepEscapeSequences | back to summary |
|---|---|
| public final void setKeepEscapeSequences(boolean keepEscapeSequences) Configures the parser to keep any escape sequences if they are present in the input (i.e. a quote escape sequence such as 2 double quotes This is disabled by default
| |
| setKeepQuotes | back to summary |
|---|---|
| public void setKeepQuotes(boolean keepQuotes) Configures the parser to keep enclosing quote characters in the values parsed from the input. Defaults to
| |
| setNormalizeLineEndingsWithinQuotes | back to summary |
|---|---|
| public void setNormalizeLineEndingsWithinQuotes(boolean normalizeLineEndingsWithinQuotes) Configures the parser to replace line separators, specified in
| |
| setParseUnescapedQuotes | back to summary |
|---|---|
| public void setParseUnescapedQuotes(boolean parseUnescapedQuotes)
Deprecated use Configures how to handle unescaped quotes inside quoted values. If set to
| |
| setParseUnescapedQuotesUntilDelimiter | back to summary |
|---|---|
| public void setParseUnescapedQuotesUntilDelimiter(boolean parseUnescapedQuotesUntilDelimiter)
Deprecated use Configures the parser to process values with unescaped quotes, and stop accumulating characters and consider the value parsed when a delimiter is found.
(defaults to
| |
| setQuoteDetectionEnabled | back to summary |
|---|---|
| public final void setQuoteDetectionEnabled(boolean quoteDetectionEnabled) Configures the parser to analyze the input before parsing to discover the quote character. The quote escape will also be detected as part of this process. Note that the detection process is not guaranteed to discover the correct quote & escape.
In this case the characters provided by
| |
| setUnescapedQuoteHandling | back to summary |
|---|---|
| public void setUnescapedQuoteHandling(UnescapedQuoteHandling unescapedQuoteHandling) Configures the handling of values with unescaped quotes.
Defaults to
| |
| trimQuotedValues | back to summary |
|---|---|
| public final void trimQuotedValues(boolean trim) Configures the parser to trim any whitespaces around values extracted from within quotes. Shorthand for
Note if
| |