Forum Discussion

Manzoor's avatar
Manzoor
New Contributor
2 years ago
Solved

How to count the columns in table

Hi Team,

I'm pulling data from the source system which have "n" columns, I wanted to count the number of columns that I'm getting from the Source System. So that to map them with the respective Target System.

Please help me out this, Thanks in advance.

  • Hi Manzoor ,

    You can use the following expression to replace the NULL values with blank in the entity object, assuming it is a flat object.

    $entity.mapValues(val => val == null ? "" : val)

    This will simply iterate over each value in the entity object, and check if the value is null, if it is, it will return an empty string otherwise it will return the original value.

5 Replies

  • Hi Manzoor ,

    Do you mind sharing more details about this? What is the source system, what is the target system? Any data samples? What do you mean by "n" columns, not sure if you are referring to the keys in the input data or if the source system is a database, then you are referring to the table columns presumably?

     

    ivicakoteski  has already proposed a solution that will count the keys in the input document, let us know if that's what you are looking for.

    • Manzoor's avatar
      Manzoor
      New Contributor

      Hi j_angelevski 

      Source System: Workday Prism

      Target System: SAP Concur

      Pulling Data from WDPrism via web service and pushing in to SAP Concur. While pulling data I'm getting few fields "Status", "Header', "Entity", "_debug".

      In " entity " I have the reqiured data. In Which there are 137 fields that I need to Map and transform in to excel table.

      Mapping and transformation in to excel is done. But columns having NULL value should be replaced by Blank value.

      Can u help me out this. Bcz among 137 fields or say as excel columns I have almost 70+ NULL values in the in each record.

      Thanks

      Manzoor.

      • j_angelevski's avatar
        j_angelevski
        Contributor III

        Hi Manzoor ,

        You can use the following expression to replace the NULL values with blank in the entity object, assuming it is a flat object.

        $entity.mapValues(val => val == null ? "" : val)

        This will simply iterate over each value in the entity object, and check if the value is null, if it is, it will return an empty string otherwise it will return the original value.

  • ivicakoteski's avatar
    ivicakoteski
    New Contributor III

    Hi Manzoor ,

    You can try the $.keys().length expression in the mapper snap. This will give you length of array that will contain all headers from the source.

     


    BR.
    Ivica