bottom

CSV Field Extractions

Attention: open in a new window. PDF 

User Rating: / 3
PoorBest 

The CSV field extraction rule allows to extract any number of fields from a source CSV record, in any order and build a new CSV record.

CSVExtraction _1

Simple CSV Extraction

In a simple CSV extraction you provide a single input separator for parsing source values and a list of indexes to extract. Indexes are numbered from 1 to n where n stands for the number of columns in the source values when splited with the given input separator.

  • The input separator is a regular expression, using special REGEXP character such as | or . can be done by backslashing them. For example, the input separator "[\|\.,]" can split input values using either a '|' or a '.' or a ','
  • You can provide several indexes to extract as a list of numer separated by a blank space. For example, using "1 2 3" means extract the 3 columns.
  • Extracted column indexes starts from 1, there are special values : -1 to randomly select a colum and * to select all the columns.

Nested CSV Structures

It is possible to parse nested CSV structure in a single configuration of a CSV Extraction. For example, let suppose that sources values have the following structure

v1.1 ; v1.2 ; v1.3 | v2.1 ; v2.2 | v3.1 ; v3.2 ; v3.3

In such a nested record we have 3 root fields made of 3, 2 and 3 child fields. Nested structure is configured by providing a sequence of input separators delimiter by a '>>'. In our example, the sequence of separators is '| >> ;'

And we have the following possible configurations of the CSV Extraction (notice that output separator is ',' )

1 >> 3  v1.3
2 >> 1 3 error bad index 3 in "v2.1 ; v2.2"
3 >> * v3.1 , v3.2 , v3.3
1 >>  -1  v1.2
1 >> -1 v1.3

It is also possible to mix nested structure paths with multiple index extract, for example: 

1 >> 3 ; 2 >> 1   v1.3 , v2.1
2 >> 1 ; 2 >> *  v2.1 , v2.1 , v2.2

Add comment


Security code
Refresh