Import Excel or CSV (Runtime Mappings) Step
  • 14 Dec 2021
  • 3 Minutes to read
  • Dark
    Light

Import Excel or CSV (Runtime Mappings) Step

  • Dark
    Light

Article Summary

Overview

The Import Excel or CSV (Runtime Mapping) step takes in CSV/Excel sheet file data as Input and maps the desired column(s) data to a Decisions Object List as Output.

This step bears similarity to the Import Excel or CSV step in that it can be used to import an Excel or CSV file into a Flow, but differs in that it allows the user to add a List of mappings dynamically at Runtime.

The following example utilizes the Project and Excel sheet found via the links below; this example demonstrates how to use the Import Excel or CSV (Runtime Mapping) step to map CSV/Excel data a Decisions object list.

Simple Example


Glossary Entry 

Step NameDescriptionLocationInputs/Outputs 
Import Excel or CSV (Runtime Mappings) Takes in a CSV or Excel file and maps the desired Column data to a Decisions Object List at Runtime. DATA > EXCEL & CSV Inputs:
File Data [FileData], Mapping [List of DynamicCSVMapping], Input File Type, Start on Row, CSV Delimiter, Ignore Quotes (Do not treat as escaped), Input File Encoding

Outputs:
Actual Columns Number [Int32], Input Line [String], Line Number [Int32], Column Number [Int32], Error Message [String], Source Value [String], Target Type [String]

Example

  1. From a Designer Project in the Decisions Studio, click the CREATE FLOW button, select Flow, provide a Name, and click CREATE.
  2. From the Flow Designer, under the top action bar, click SETUP INPUT DATA, then click DEFINE.
  3. From the Input Data editor, NAME the data "ExcelSheet", then under Type, select File Data. Click Save, then close the window via X.
  4. Next, from the FAVORITE STEPS category under the Toolbox tab, attach a Create Data to the Start step. Then, navigate to the Create Data step's Properties and click SHOW EDITOR. 
    This step will be used to establish the required DynamicCSVMapping input to help the Import step know how to distribute data to the desired columns. 


  5. From the Data Definitions window, set the Name to MappingData and the Type to DynamicCSVMapping, check Is List, then click CLOSE.

  6. Navigate back to the Create Data step's Properties and set the Mapping to Constant; then, click ADD NEW to define each Mapping Data Field. 

    Each field represents a different Column in the spreadsheet, along with a Column Number representing each one, starting with 0. Add three Columns numbered 0-2 with the following configurations (Leave each FieldType as String):
    • Column Number: 0, FieldName: EmailAddress
    • Colum Number: 1, FieldName: Id
    • Column Number: 2. FieldName: Name

  7. Attach an Import Excel or CSV (Runtime Mappings) step from the DATA > EXCEL & CSV category in the Toolbox tab, to the Create Data step. 

  8. Navigate to the Properties for the Import Excel or CSV step, set Output Data Type to AccountInfo.

    Note that the Output Data Type must output a Data Type that contains Data Members whose Names and Types match the desired Columns and Column Data Types respectively. For this example, a Flow Structure will work.
    If there are Data Member Names that are missing from the Data Structure and the DynamicCSVMapping expects those Column Names, then an error will occur.
  9. Leave each option under ERROR HANDLING set as Add Outcome.

    Alternately users have the option to also choose Throw Exception or Ignore and Continue.
  10. Under INPUT DATA > Input File Type, select Excel_xlsx from the drop-down menu. Set Start on Row to 2. 

    For this example, setting Start on Row to 2 skips the first row in the Excel file which is occupied by a Header. 

  11. Under INPUTS, map ExcelSheet to File Data. Then, map MappingData to Mapping

  12. From the FLOW MANAGEMENT category of the Toolbox, attach an End step to each path of the Import Excel or CSV (Runtime Mappings) step. Name each End step by providing a value in their Data Property.

  13. Save the Flow, then if desired, close the Flow Designer via X. 



Debug

  1. From the Flow Designer, select the Debug link from the top action bar. 
  2. Click and drag, or use the CHOOSE FILE button to add the Test Excel file. Then click START DEBUGGING. 
  3. After the Flow runs, select Import Excel or CSV (Runtime Mapping) > Execution 1 > View Input/Output Data
    The resulting Output data will demonstrate the imported data from the Excel sheet sorted into each Column by the defined Mapping Data.



Was this article helpful?