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.