Parse a file

As part of creating or modifying a discovery pattern, you can use the Parse file operation to extract information from a file and create variables to contain the extracted information.

Before you begin

Navigate to the relevant pattern step:

  1. On the pattern form, select the relevant identification section for Discovery.

    Alternatively, select the relevant identification or connection section for Service Mapping.

  2. Select the relevant pattern step or click to add a step.

Basic knowledge of programming is desirable.

Role required: pd_admin

About this task

Alternatively, you can use traffic-based connections to create a parse file step in the relevant CI pattern as described in Fine-tune patterns using traffic-based discovery.

Procedure

  1. Select Parse file from the Operation list.
  2. Specify the file path in Select file.
    You can use variables. You can also use values from a temporary tabular variable: from a specific field or a specific column in a table sequentially, starting from the first row. For more information, see Enter values and variables in patterns.

    To specify the actual file, click Browse, navigate to the file, and click Select.

    Important: Avoid entering a specific path to a location or file because it can be different on different operating systems. You should use variables for paths.
  3. Select the relevant parsing strategy from the Define Parsing list and define parsing criteria.
    Parsing strategy Description

    Oracle

    LDAP file

    XML file

    INI file

    Properties file

    JSON file (custom)

    Horizontal file parsing strategy (not vertical). You can use this parsing strategy only for text files. For more information, see Parse text from a horizontal file.
    Vertical File Retrieve text from a structured text file where each set of data spans multiple lines. For more information, see Parse text from a vertical file.

    After Keyword

    Retrieve text directly following a specific keyword. For more information, see Parse text using keyword, command, and positional type.

    Command Line Java Style

    Retrieve the value of a command-line parameter using Java-style parameters. For more information, see Parse text using keyword, command, and positional type.

    Command Line Unix Style

    Retrieve the value of a command-line parameter using standard Unix parameters. For more information, see Parse text using keyword, command, and positional type.

    Position From End

    Retrieve text specified by its position from the end of the line. For more information, see Parse text using keyword, command, and positional type.

    Position From Start

    Retrieve text specified by its position from the beginning of the line. For more information, see Parse text using keyword, command, and positional type.

    Regular Expression Retrieve text specified by a regular expression. This option requires familiarity with Regex Java syntax. For more information, see Parse text using a regular expression.
    Delimited Text Retrieve text specified by delimiters and position within the line (the most common way to retrieve text from generic text files). See Parse text using delimited text.
  4. Select Terminate to stop discovery if no results are found.
  5. If in Debug mode, test the step by clicking Test and checking that the operation brings the result you expected.

Example

You can use the Parse File operation to extract data on prices and authors from an xml file using the XML File parsing strategy.


Displaying the Advanced Variables pane

What to do next