IBM Support

How to Create multi-valued entries in a CSV file.

Question & Answer


Question

The TDI Documentation states the following about the CSV Parser: "On output, multi-valued attributes only deliver their first value." Is there a way to work around this?

Answer

Scripting could be used in the multi-valued attribute's 'Output Map Assignment'.
Here is sample script which creates an entry in the CSV record which will contain all the values of the multi-valued attribute.

    var Array = work.getAttribute("users");
    var String = "";                                                      
                                                                         
    if (Array !=null && Array.size()>0)                                  
    {                                                                    
    String = Array.getValue(0);                                        
    for (i=1;i<Array.size();i++)                                        
    {                                                                    
    var role = Array.getValue(i);                                      
    String = String + "," + role;                                      
    }                                                                    
    }                                                                    
    return String


This is a view of the script assigned to an Attribute defined in the Connector's Output Map.


Example of the Data created by the script:
      cn;sn;objectClass
      John Doe;Doe;top,person,inetOrgPerson

The attributes are separated by the CSV Parser 'Field Separator' symbol defined on the Connection tab for the File System Connector. In this example, the separator is defined as the " ; ".

The values of the multi-valued attribute are separated by " , " which is defined in the definition of the Attribute of the Connector's Output Map.

[{"Product":{"code":"SSCQGF","label":"Tivoli Directory Integrator"},"Business Unit":{"code":"BU008","label":"Security"},"Component":"General","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0;7.1;7.1.1;7.2","Edition":"All Editions","Line of Business":{"code":"LOB24","label":"Security Software"}}]

Document Information

Modified date:
16 June 2018

UID

swg21512041