Class CsvFileImportProcessor
java.lang.Object
org.pentaho.di.trans.steps.fileinput.text.BaseFileImportProcessor
org.pentaho.di.trans.steps.fileinput.text.CsvFileImportProcessor
This class is used to process CSV files in CsvInput step
-
Field Summary
Fields inherited from class org.pentaho.di.trans.steps.fileinput.text.BaseFileImportProcessor
debug, encodingType, inputFields, log, message, reader, replaceMeta, rowNumber, samples, showSummary, transMeta -
Constructor Summary
ConstructorsConstructorDescriptionCsvFileImportProcessor(CsvInputMeta meta, TransMeta transMeta, BufferedInputStreamReader reader, int samples, boolean showSummary) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectClones the metadata object.protected TextFileInputFieldDTOconvertFieldToDto(Object field) Converts a field to a Data Transfer Object (DTO).protected Object[]convertLineToRow(TextFileLine textFileLine, Object strinfo, org.pentaho.di.core.row.RowMetaInterface outputRowMeta, org.pentaho.di.core.row.RowMetaInterface convertRowMeta, boolean failOnParseError) Converts a line from the file into a row of data.protected StringRetrieves the enclosure character used in the file.protected StringRetrieves the escape character used in the file.protected ObjectRetrieves a field from the metadata at the specified index.protected intReturns the number of fields in the file.protected StringgetFieldFormat(Object field) Retrieves the format of a field.protected intgetFieldLength(Object field) Retrieves the length of a field.protected StringgetFieldName(Object field) Retrieves the name of a field.protected intgetFieldPrecision(Object field) Retrieves the precision of a field.protected voidgetFields(org.pentaho.di.core.row.RowMetaInterface rowMeta) Populates the row metadata with field information.protected intgetFieldType(Object field) Retrieves the type of a field.protected StringgetFieldTypeDesc(Object field) Retrieves the type description of a field.protected intRetrieves the file format type number.protected intRetrieves the number of header lines in the file.protected booleanChecks if the file has a header.protected voidinitializeField(Object field, DecimalFormatSymbols dfs) Initializes a field with the given decimal format symbols.protected voidsetAllFieldsToStringType(Object metaObj) Sets all fields in the metadata to string type.protected voidsetFieldTypeInfo(Object field, org.pentaho.di.core.util.StringEvaluator evaluator, List<org.pentaho.di.core.util.StringEvaluationResult> evaluationResults, org.pentaho.di.core.util.StringEvaluationResult strEvaluationResult) Sets type information for a field based on evaluation results.Methods inherited from class org.pentaho.di.trans.steps.fileinput.text.BaseFileImportProcessor
analyzeFile, getInputFields, getInputFieldsDto, getMessage
-
Constructor Details
-
CsvFileImportProcessor
public CsvFileImportProcessor(CsvInputMeta meta, TransMeta transMeta, BufferedInputStreamReader reader, int samples, boolean showSummary)
-
-
Method Details
-
getFieldCount
protected int getFieldCount()Description copied from class:BaseFileImportProcessorReturns the number of fields in the file.- Specified by:
getFieldCountin classBaseFileImportProcessor- Returns:
- the field count
-
getFieldName
Description copied from class:BaseFileImportProcessorRetrieves the name of a field.- Specified by:
getFieldNamein classBaseFileImportProcessor- Parameters:
field- the field to retrieve the name for- Returns:
- the field name
-
getFieldTypeDesc
Description copied from class:BaseFileImportProcessorRetrieves the type description of a field.- Specified by:
getFieldTypeDescin classBaseFileImportProcessor- Parameters:
field- the field to retrieve the type description for- Returns:
- the field type description
-
getFieldType
Description copied from class:BaseFileImportProcessorRetrieves the type of a field.- Specified by:
getFieldTypein classBaseFileImportProcessor- Parameters:
field- the field to retrieve the type for- Returns:
- the field type
-
getFieldLength
Description copied from class:BaseFileImportProcessorRetrieves the length of a field.- Specified by:
getFieldLengthin classBaseFileImportProcessor- Parameters:
field- the field to retrieve the length for- Returns:
- the field length
-
getFieldPrecision
Description copied from class:BaseFileImportProcessorRetrieves the precision of a field.- Specified by:
getFieldPrecisionin classBaseFileImportProcessor- Parameters:
field- the field to retrieve the precision for- Returns:
- the field precision
-
getFieldFormat
Description copied from class:BaseFileImportProcessorRetrieves the format of a field.- Specified by:
getFieldFormatin classBaseFileImportProcessor- Parameters:
field- the field to retrieve the format for- Returns:
- the field format
-
hasHeader
protected boolean hasHeader()Description copied from class:BaseFileImportProcessorChecks if the file has a header.- Specified by:
hasHeaderin classBaseFileImportProcessor- Returns:
- true if the file has a header, false otherwise
-
getHeaderLines
protected int getHeaderLines()Description copied from class:BaseFileImportProcessorRetrieves the number of header lines in the file.- Specified by:
getHeaderLinesin classBaseFileImportProcessor- Returns:
- the number of header lines
-
getEnclosure
Description copied from class:BaseFileImportProcessorRetrieves the enclosure character used in the file.- Specified by:
getEnclosurein classBaseFileImportProcessor- Returns:
- the enclosure character
-
getEscapeCharacter
Description copied from class:BaseFileImportProcessorRetrieves the escape character used in the file.- Specified by:
getEscapeCharacterin classBaseFileImportProcessor- Returns:
- the escape character
-
getFileFormatTypeNr
protected int getFileFormatTypeNr()Description copied from class:BaseFileImportProcessorRetrieves the file format type number.- Specified by:
getFileFormatTypeNrin classBaseFileImportProcessor- Returns:
- the file format type number
-
getField
Description copied from class:BaseFileImportProcessorRetrieves a field from the metadata at the specified index.- Specified by:
getFieldin classBaseFileImportProcessor- Parameters:
metaObj- the metadata objectindex- the index of the field- Returns:
- the field object
-
getFields
protected void getFields(org.pentaho.di.core.row.RowMetaInterface rowMeta) throws org.pentaho.di.core.exception.KettleStepException Description copied from class:BaseFileImportProcessorPopulates the row metadata with field information.- Specified by:
getFieldsin classBaseFileImportProcessor- Parameters:
rowMeta- the row metadata to populate- Throws:
org.pentaho.di.core.exception.KettleStepException- if an error occurs while populating the metadata
-
cloneMeta
Description copied from class:BaseFileImportProcessorClones the metadata object.- Specified by:
cloneMetain classBaseFileImportProcessor- Returns:
- the cloned metadata object
-
initializeField
Description copied from class:BaseFileImportProcessorInitializes a field with the given decimal format symbols.- Specified by:
initializeFieldin classBaseFileImportProcessor- Parameters:
field- the field to initializedfs- the decimal format symbols
-
setFieldTypeInfo
protected void setFieldTypeInfo(Object field, org.pentaho.di.core.util.StringEvaluator evaluator, List<org.pentaho.di.core.util.StringEvaluationResult> evaluationResults, org.pentaho.di.core.util.StringEvaluationResult strEvaluationResult) Description copied from class:BaseFileImportProcessorSets type information for a field based on evaluation results.- Specified by:
setFieldTypeInfoin classBaseFileImportProcessor- Parameters:
field- the field to set type information forevaluator- the string evaluatorevaluationResults- the list of evaluation resultsstrEvaluationResult- the advised evaluation result
-
convertLineToRow
protected Object[] convertLineToRow(TextFileLine textFileLine, Object strinfo, org.pentaho.di.core.row.RowMetaInterface outputRowMeta, org.pentaho.di.core.row.RowMetaInterface convertRowMeta, boolean failOnParseError) throws org.pentaho.di.core.exception.KettleException Description copied from class:BaseFileImportProcessorConverts a line from the file into a row of data.- Specified by:
convertLineToRowin classBaseFileImportProcessor- Parameters:
textFileLine- the line of text to convertstrinfo- metadata informationoutputRowMeta- the output row metadataconvertRowMeta- the converted row metadatafailOnParseError- whether to fail on parse errors- Returns:
- the converted row as an object array
- Throws:
org.pentaho.di.core.exception.KettleException- if an error occurs during conversion
-
setAllFieldsToStringType
Description copied from class:BaseFileImportProcessorSets all fields in the metadata to string type.- Specified by:
setAllFieldsToStringTypein classBaseFileImportProcessor- Parameters:
metaObj- the metadata object
-
convertFieldToDto
Description copied from class:BaseFileImportProcessorConverts a field to a Data Transfer Object (DTO).- Specified by:
convertFieldToDtoin classBaseFileImportProcessor- Parameters:
field- the field to convert- Returns:
- the field DTO
-