Creating a Parse Delimited rule
Create a Parse Delimited rule to upload data into your Pega Platform system from an external file or files. The rule extracts the text between the delimiter characters and stores it in a Single Value property, or as one element of a Value List property.
In the header of Dev Studio, click.
On the Create page, in the Label field, enter an identifier.
This key value is arbitrary.
In the Record Type field, enter a valid Java identifier value.
This key value is arbitrary.
In the Context section, in the Apply to field, select the class to which this rule applies.
The list of available class names depends on the ruleset that you select. Each class can restrict the application of rules to an explicit set of rulesets, as specified on the Advanced tab of the class form.
Click Create and open.The Parse Delimited rule form opens on the Parse rules tab. Use this tab to identify the input character that delimits fields in the input file, and configure a mapping from parsed input data to the clipboard or to other destinations.
On the Parse rules tab, in the Field format field, select one of the following formats:
- Comma-Separated Values (CSV) – Select this option to
indicate that the contents of the file are in CSV format (available as a file export
option from Microsoft Excel). Field values are separated by a single comma. Field values
that contain a comma are surrounded by quotation marks.
If you choose this option, continue to step 8.
- Custom Definition – Select this option to indicate that the contents of the file use a character or character sequence to delimit fields, as defined on the Delimiter and Escape character fields of this tab.
- Comma-Separated Values (CSV) – Select this option to indicate that the contents of the file are in CSV format (available as a file export option from Microsoft Excel). Field values are separated by a single comma. Field values that contain a comma are surrounded by quotation marks.
If you chose the Custom Definition field format in step 6, complete the following fields:
In the Delimiter field, enter the character that separates each field in the input record.
Enter one of the following characters:
You cannot enter an octal or hexadecimal character value.
- A single character
- An equals sign (=) followed by a property reference in the form pagename.propertyname, where this property contains the separator character at runtime
- One of the two-character escape sequences \n for newline, \r for return, \f for form feed, \0 for the null character, or \t for a tab character
In the Escape character field, specify a character that, when it immediately precedes the delimiter character, causes that one instance of the delimiter character to be ignored and become part of the input data.If you leave this field blank, the system uses a backslash character as the escape character.If a comma is the delimiter character, and you enter a backward slash (\) in this field, input text containing:
parsley, sage, rosemary\, and thyme,
produces three parsed segments. The last segment contains a comma (and no backward slash):
rosemary, and thyme
To define the escape character as the value of a property reference, enter an equals sign (=) followed by a property reference in the form pagename.propertyname, where this property contains the escape character at run time.
In the Processing method section, in the Method list, select one of the following options to indicate how this parse rule operates at run time:
If the first record in an input file contains header information that identifies the values in all of the later records, you can choose Build tag list in a first Parse Delimited rule, and Use tag list in a second Parse Delimited rule.If you plan to validate the page that contains the imported rows and save it as an instance in the database, the tags must identify existing, defined properties.
- Build tag list – Select this option to store the output of
this rule as the value of a single Value List mode property named
pyTagList on a new clipboard page named Work.
This option generates valid property names from the data in the file and records them in each value of the Value List property. (Only certain characters can appear in property names; the system skips hyphens and any other invalid characters found in the input.)
- Use tag list – Use a tag list property (pyTagList on a clipboard page named Work) to store the elements in this record.
- Use parse details – Use this option to apply the parse details specified in this rule.
- Build value list – Store the output of this rule as the
values of a single Value List property. Enter only one row in the
Parsing Details array:
- Select Clipboard as the Map To field value.
- Enter the name of this Value List property in the Map to key field.
- Build tag list – Select this option to store the output of this rule as the value of a single Value List mode property named pyTagList on a new clipboard page named Work.
To enable the system to ignore remaining data in the input record in the input data stream, select Drain remaining data. If cleared, processing continues from the last position before the data was ignored.
In the Parsing details section, define the processing for each input field. Enter rows in the order in which the data appears in the input file.
To mark an element as required, select Required.
If the data in the input stream is exhausted but parse details marked Required remain, parsing halts. Data processed so far remains available on the clipboard.
In the Description field, enter a description of this parse step.
In the Map to field, select the action to take in this parse step:This is a required field if the Method field is set to build value list.
- Parse XML Rule
- Delimited Parse Rule
- Structured Parse Rule
- A function rule in a MapTo library
In the Map to key field, identify the value of a key or value used in conjunction with the value you entered into the Map to field:This is a required field if the Method field is set to build value list.
- If the Map to value is Clipboard, enter a property reference on the clipboard that is to receive the value.
- If the Map to value is Parse XML Rule, enter a namespace value that is the first key part of that rule, plus a period, and a Record Type value for the Parse XML rule key. You can also enter only a record type value to indicate that the namespace of the Parse XML rule is the same as the namespace of this rule.
- If the Map to value is Delimited Parse Rule, enter a Record Type value.
- If the Map to value is Structured Parse Rule, enter a Record Type value.
- If the Map to value is a Rule-Utility-Function from a MapTo library, identify a property reference to use as the third parameter of the function.