This documentation supports the 11.2 version of BMC Discovery.

To view an earlier version of the product, select the version from the Product version menu.

Importing CSV data

It is often very easy to extract information from applications and devices and store it as CSV data. Data can be exported from BMC Discovery in this format. For more information, see CSV API. You can also import CSV data into BMC Discovery (for example, you might have information about a number of hosts that you want to import).

You can import a CSV file using the Import CSV Data page described in the following section, and you can choose delimiters other than commas when using this page. Alternatively, if you have command line access, you can use the tw_imp_csv utility.

Incorrect usage may result in data loss

  • Using Import CSV Data incorrectly can cause irreparable damage to your data, because the data you submit using this page is applied directly to the production data without any validation. Before using the Import CSV Data page, ensure that you fully understand the system taxonomy and the changes that you plan to make to your data.
  • Always back up your datastore before using this tool.

Do not import the following node kinds

  • You must never import DDD nodes.
  • You should avoid importing Host nodes and other system maintained nodes. If in doubt, contact Customer Support.

The following topics are covered in this section:

To import a CSV file

  1. From the Model section, click CSV Import.
    The following screen illustrates the Import CSV Data page with the host container node kind selected.


    The following table describes the options on this page:

      

    Field Name

    Details

    File To Upload

    Click Browse to display a file browser window, select the file to import, and click Open.

    Update Mode

    Select the mode to use for updates. Choose one of the following from the list:

    • Create And Update—Nodes are created and updated as required.
    • Create Only—New nodes are created; existing nodes are not updated.
    • Update Only—New nodes are not created; existing nodes are updated.
    • Delete Only—Nodes with match are deleted; no other nodes are created or updated.

    Node Kind

    Choose the type of node to import from the list. The node kind can be one of any defined in the taxonomy. Changing the node kind updates the Keys field dynamically.

    Keys

    Choose the key or keys for each entry. You must select at least one key. Taxonomy-defined keys are marked with a red asterisk (*). Use the check boxes if you want to use other keys. The following quick-selection links are provided at the top of the keys field:

    • Key Attributes—Selects just the taxonomy-defined keys.
    • None—Clears any selection.

    Note: The behavior differs from the tw_imp_csv utility, which uses the first column of the input file as the key unless others are specified. When controlling an import using the UI Import page, only the keys that are selected are used.

    Delimiter

    Choose the required delimiter from the list: Comma, Semicolon, or Tab.

    Logging Level

    Choose the logging level from the list: Debug, Info, Warning, Error, or Critical.

  2. To import the CSV file, click Apply.

For examples of using the CSV importer, see CSV import examples.

File format

The CSV file represents a two-dimensional table with rows separated by newlines, and columns separated by commas. Commas can be included in that data but must be enclosed between double quote characters (").

Column names that do not begin with a hash character (#) are treated as names of attributes on the node.

Column names that begin with a hash character are treated as key expressions. Key expressions are used to create or update a relationship to another node. For more information, see Relationships.

Keys

The CSV importer searches the datastore for nodes of a specified kind that have a key or keys matching rows in the supplied CSV data. Where the keys match, the node is updated, or deleted and recreated, depending on the options selected. The first attribute column is used as a key by default. This can be overridden with the Keys option described in the preceding table.

Relationships

Relationship columns describe a relationship between the node being modified and one or more other nodes. Relationships are defined using a full key expression. The following example shows a link to a single node:

#role:relationship:role:kind.attribute

The following example shows a link to multiple target nodes. Notice that you must surround the relationship definition and data in double quotes so that the subsequent attributes are not treated as local nodes:

"#role:relationship:role:kind.attribute,attribute,attribute"

The first role part is the kind of the role that the node being created or updated plays in the relationship. The relationship part is the kind of the relationship being created. The second role part is the kind of role that the other node plays in the relationship. The kind part is the node kind of the other node. Finally, the attribute or attribute list is the name of the attribute used to find the other node. For information about relationships, see Node lifecycle.

Only a single traversal is supported.

Type conversion

By default, the CSV importer attempts to convert attribute values to the type defined in the taxonomy. If an attribute is not defined, it is left as a string. If a conversion fails, it is also left as a string.

For list types, the value in the CSV file must be in Python list syntax.

When the tw_imp_csv utility is used with the --force option, all attributes are left as strings.

Related topics

Was this page helpful? Yes No Submitting... Thank you

Comments