Skip to main content

CsvSplitter

Split files with Coma-Separated values

Notes

Processes files with comma-separated values (or other delimiters like tabs) by dividing them into individual documents, one per line.

Parser Handler Compatibility

This functionality can be applied as either a pre-parse or post-parse handler.

Examples

The following example demonstrates how to use the CsvSplitter to split a CSV file into multiple documents.

Sample CSV File contentTypes:

'clientId','clientName','clientOrg','orgDesc'
'123','Joe Dalton','ACME Inc.','Organization\'s description'
'345','Avrel Dalton','Daisy Town','Another one'

Result:

The file will be split into two documents, one for each row after the header row:

Document 1

  • Reference: 123
  • Content: ACME Inc Organization's description

Document 2

  • Reference: 345
  • Content: 'Daisy Town Another one
handler:
class: CsvSplitter
separatorCharacter: ","
quoteCharacter: "'"
escapeCharacter: \
useFirstRowAsFields: true
linesToSkip: 0
referenceColumn: clientId
contentColumns:
- clientOrg
- orgDesc

Usage

Full configuration skeleton, with every option and its default
class: CsvSplitter
contentColumns:
- string
discardOriginal: false
escapeCharacter: string
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
label: string
linesToSkip: 0
quoteCharacter: string
referenceColumn: string
separatorCharacter: string
useFirstRowAsFields: false

Properties

PropertyTypeRequiredDefault
contentColumnsstring[]No-
discardOriginalbooleanNofalse
escapeCharacterstringNo\
fieldMatcherTextMatcherNoTextMatcher
labelstringNo-
linesToSkipintegerNo0
quoteCharacterstringNo"
referenceColumnstringNo-
separatorCharacterstringNo,
useFirstRowAsFieldsbooleanNofalse

Property Details

contentColumns

Lists the columns whose values will form the document content.

discardOriginal

Discard the original document after the split is performed.

escapeCharacter

Sets the character used to escape special characters within field values.

fieldMatcher

Matches document fields based on specified patterns and methods

label

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.

linesToSkip

Specifies the number of initial lines in the CSV file to skip during processing

quoteCharacter

Defines the character used to enclose fields containing special characters, like quotes or separators.

referenceColumn

Identifies the column whose values will be used as document references.

separatorCharacter

Specifies the character used to separate fields in the CSV file, such as a comma or tab.

useFirstRowAsFields

Indicates whether the first row of the CSV file should be treated as field names.