CSV

Another popular integration format is Comma Separated Values (CSV). CSV is convenient because it can be edited by the most popular spreadsheet programs.

Procedure 16.4. To Load Data Using CSV Files

  1. Create an Inbound Interface

    Platform uses Inbound Interfaces to consume data in Comma-separated Value (CSV) format. The Inbound Interface consists of a definition for the format of the inbound data, and a processor which should be used to write the values to the database.

    Open your MPT and navigate the Outline view to Inbound Interfaces. Right-click and press "Add Inbound Interface".
    images/download/attachments/144835944/AddInterface-version-1-modificationdate-1645135573000-api-v2.png

    For this example, we will create an Inbound Interface for loading Enterprise data. Name the interface EnterpriseLoad.
    images/download/attachments/144835944/NameToEnterpriseLoad-version-1-modificationdate-1645135582000-api-v2.png

    You'll notice that the interface has two tabs: Format and Processor. We use the Format tab to specify what the fields are which are present in the interface, which are required and optional, what the expected formats are for dates and numbers, etc. We use the Processor tab to specify how we get the data out of the CSV and into the database.

    Next, we'll specify the Format of the interface. Click Add Fields, then click Enterprise within the list of Models.
    images/download/attachments/144835944/AddFields-version-1-modificationdate-1645135592000-api-v2.png
    Choose Name and Description.
    images/download/attachments/144835944/NameAndDescriptionFields-version-1-modificationdate-1645135600000-api-v2.png

  2. Configure the Processor

    Now we can specify a Processor for this simple interface. Switch to the Format tab. It should already say "Default Model CSV Processor". This means it will use Model actions to process the data.

    You can specify a default custom model name and/or action in the interface itself, or these can be provided as fields within the CSV. For this example, we will provide defaults:
    images/download/attachments/144835944/ProcessorAndDefaults-version-1-modificationdate-1645135608000-api-v2.png
    Now save and submit your MPT to your server. At this point, you have an Inbound Interface which you can use to load Enterprises.

  3. Test Load Using load-data Ant Target

    To test, go back to the Format tab and click the Export Sample CSV button.
    images/download/attachments/144835944/export_sample_csv_button-version-1-modificationdate-1645135618000-api-v2.png

    This will produce a sample CSV which you can populate with some test data, like the following:
    images/download/attachments/144835944/EntCsv-version-1-modificationdate-1645135628000-api-v2.png
    Save the CSV file in data/ as EnterpriseFile.csv. We can load this CSV using the dataset's load-data target. To achieve this, add an InboundInterface entry to your LoadData.xml file:
    <InboundInterfaceFile inboundInterface="ZBKS.EnterpriseLoad">data/EnterpriseFile.csv</InboundInterfaceFile>
    After loading data, you should see those two Enterprises in your database:
    images/download/attachments/144835944/EntsInDb-version-1-modificationdate-1645135643000-api-v2.png