public class CSVReader extends TextReader
DataEndpoint.StateEOF, readercurrentRecord, fieldNames, lastRow, startingRowfieldLineage, recordLineagelastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYBUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEid, log, name, TIMESTAMP_FORMAT| Constructor and Description |
|---|
CSVReader(File file) |
CSVReader(Reader reader) |
| Modifier and Type | Method and Description |
|---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException. |
protected Record |
addLineage(Record record) |
protected boolean |
fillRecord(Record record) |
long |
getColumnNumber() |
String |
getEndingQuote()
Returns the string used to mark the ending of text values that may contain commas and other special characters (defaults to double quote - ").
|
String |
getFieldSeparator() |
String[] |
getLineSeparators()
Returns the strings used to separate records or
null if none were explicitly assigned. |
LineParser |
getParser() |
String |
getQuoteChar()
Returns the starting quote - same as calling getStartingQuote() (defaults to double quote - ").
|
String |
getStartingQuote()
Returns the string used to mark the beginning of text values that may contain commas and other special characters (defaults to double quote - ").
|
boolean |
isAllowMultiLineText()
Indicates if line separators are allowed inside quoted fields.
|
boolean |
isAllowQuoteInField()
Indicates if unescaped quotes are allowed in fields (default to false).
|
boolean |
isLineageSupported() |
boolean |
isTrimFields()
Indicates if space and tab characters at the beginning and ending of non-quoted-values should be removed.
|
static RecordList |
parse(String text,
String fieldSeparator,
String quoteChar,
Boolean allowMultiLineText)
Utility method to quickly parse lines of CSV text.
|
static RecordList |
parse(String text,
String fieldSeparator,
String quoteChar,
Boolean allowMultiLineText,
Boolean trimFields)
Utility method to quickly parse lines of CSV text.
|
static Record |
parseLine(String line,
String fieldSeparator,
String quoteChar,
Boolean allowMultiLineText)
Utility method to quickly parse a line of CSV text.
|
static Record |
parseLine(String line,
String fieldSeparator,
String quoteChar,
Boolean allowMultiLineText,
Boolean trimFields)
Utility method to quickly parse a line of CSV text.
|
CSVReader |
setAllowMultiLineText(boolean allowMultiLineText)
Indicates if line separators are allowed inside quoted fields.
|
CSVReader |
setAllowQuoteInField(boolean allowQuoteInField)
Indicates if unescaped quotes are allowed in fields (default to false).
|
CSVReader |
setEndingQuote(String endingQuote)
Assigns the string used to mark the ending of text values that may contain commas and other special characters (defaults to double quote - ").
|
CSVReader |
setFieldNames(Collection<String> fieldNames) |
CSVReader |
setFieldNames(String... fieldNames) |
CSVReader |
setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) |
CSVReader |
setFieldSeparator(char columnSeparator) |
CSVReader |
setFieldSeparator(String columnSeparator) |
CSVReader |
setLastRow(int lastRow) |
CSVReader |
setLineSeparator(String lineSeparator)
Indicates the string used to separate records.
|
CSVReader |
setLineSeparators(String... lineSeparators)
Indicates the string or strings used to separate records.
|
CSVReader |
setQuoteChar(char quoteChar) |
CSVReader |
setQuoteChar(String quoteChar)
Assigns startingQuote and endingQuote to the same value (defaults to double quote - ").
|
CSVReader |
setSaveLineage(boolean saveLineage) |
CSVReader |
setSkipEmptyRows(boolean skipEmptyRows)
Indicates that rows with only null values should not be returned by the reader (default is false).
|
CSVReader |
setStartingQuote(String startingQuote)
Assigns the string used to mark the beginning of text values that may contain commas and other special characters (defaults to double quote - ").
|
CSVReader |
setStartingRow(int startingRow) |
CSVReader |
setTrimFields(boolean trimFields)
Indicates if space and tab characters at the beginning and ending of non-quoted-values should be removed.
|
available, close, getFile, getLineNumber, open, readImplgetFieldNames, getLastRow, getStartingRow, isFieldNamesInFirstRow, isSkipEmptyRows, readgetBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isSaveLineage, peek, pop, push, skipdecrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringaddElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescriptionpublic static Record parseLine(String line, String fieldSeparator, String quoteChar, Boolean allowMultiLineText)
line - the delimited line of text to parsefieldSeparator - quoteChar - allowMultiLineText - public static Record parseLine(String line, String fieldSeparator, String quoteChar, Boolean allowMultiLineText, Boolean trimFields)
line - fieldSeparator - quoteChar - allowMultiLineText - trimFields - public static RecordList parse(String text, String fieldSeparator, String quoteChar, Boolean allowMultiLineText)
text - the delimited lines of text to parsefieldSeparator - quoteChar - allowMultiLineText - public static RecordList parse(String text, String fieldSeparator, String quoteChar, Boolean allowMultiLineText, Boolean trimFields)
text - fieldSeparator - quoteChar - allowMultiLineText - trimFields - public String getFieldSeparator()
public CSVReader setFieldSeparator(char columnSeparator)
public String getQuoteChar()
getStartingQuote()public CSVReader setQuoteChar(char quoteChar)
public CSVReader setQuoteChar(String quoteChar)
setStartingQuote(String)
setEndingQuote(String)public String getStartingQuote()
public CSVReader setStartingQuote(String startingQuote)
public String getEndingQuote()
public CSVReader setEndingQuote(String endingQuote)
public String[] getLineSeparators()
null if none were explicitly assigned.public CSVReader setLineSeparators(String... lineSeparators)
public CSVReader setLineSeparator(String lineSeparator)
public boolean isAllowMultiLineText()
public CSVReader setAllowMultiLineText(boolean allowMultiLineText)
public boolean isAllowQuoteInField()
public CSVReader setAllowQuoteInField(boolean allowQuoteInField)
public boolean isTrimFields()
Character.isWhitespace(int) will be removed (not only spaces and tabs).
This is helpful when CSV files may contain spaces between the commas (field separators) and values.true.public CSVReader setTrimFields(boolean trimFields)
Character.isWhitespace(int) will be removed (not only spaces and tabs).
This is helpful when CSV files may contain spaces between the commas (field separators) and values.true.public LineParser getParser()
public long getColumnNumber()
public boolean isLineageSupported()
isLineageSupported in class DataReaderprotected Record addLineage(Record record)
addLineage in class TextReaderpublic DataException addExceptionProperties(DataException exception)
EndpointDataException. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties in class TextReaderprotected boolean fillRecord(Record record) throws Throwable
fillRecord in class AbstractReaderThrowablepublic CSVReader setSkipEmptyRows(boolean skipEmptyRows)
AbstractReadersetSkipEmptyRows in class AbstractReaderpublic CSVReader setFieldNames(String... fieldNames)
setFieldNames in class AbstractReaderpublic CSVReader setFieldNames(Collection<String> fieldNames)
setFieldNames in class AbstractReaderpublic CSVReader setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
setFieldNamesInFirstRow in class AbstractReaderpublic CSVReader setStartingRow(int startingRow)
setStartingRow in class AbstractReaderpublic CSVReader setLastRow(int lastRow)
setLastRow in class AbstractReaderpublic CSVReader setSaveLineage(boolean saveLineage)
setSaveLineage in class DataReaderCopyright (c) 2006-2025 North Concepts Inc. All Rights Reserved.