Topic
  • 6 replies
  • Latest Post - ‏2013-10-09T08:17:19Z by paul.brett
mahesh15
mahesh15
5 Posts

Pinned topic How to generate seperate files based on a condition

‏2013-06-26T13:44:25Z |

Hi,

I have a requirement of generating seperate files based on unique values of a input field.I have created a function map using UNIQUE,EXTRACT functions but it is creating the file only for the first unique value.

Scenario is given below

Input
------
1,ABC,XYZ
1,ABC,XYZ
2,ABC,XYZ
2,ABC,XYZ
3,ABC,XYZ
3,ABC,XYZ

Outputs
-------
File1
1,ABC,XYZ
1,ABC,XYZ

File2
2,ABC,XYZ
2,ABC,XYZ

File3
3,ABC,XYZ
3,ABC,XYZ

Any help in this is really appreciated

 

Thanks,

Mahesh

  • edi1999
    edi1999
    32 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-06-26T14:00:11Z  

    IF(Field_1 = "1", FunctionalMap1) | IF(Field_1 = "2", FunctionalMap2 | IF(Field_1 = "3", FunctionalMap3), NONE)

  • mahesh15
    mahesh15
    5 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-06-26T14:08:20Z  
    • edi1999
    • ‏2013-06-26T14:00:11Z

    IF(Field_1 = "1", FunctionalMap1) | IF(Field_1 = "2", FunctionalMap2 | IF(Field_1 = "3", FunctionalMap3), NONE)

    Hi Edi,

    Thanks for the quick reply.

    The values are dynamic and it can be of any number.

    I have just given 1,2 3 as sampe.

     

    -Mahesh

  • TarunB
    TarunB
    211 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-06-26T21:19:30Z  

    Sounds like you want to read up on Control Break Logic. Apply this to your input type tree, which if structured properly can then feed into an output card functional map call placed in a (0:s) ranged cell.

    The code within the functional map will of course be a simple PUT statement.

  • mahesh15
    mahesh15
    5 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-06-27T09:16:39Z  
    • TarunB
    • ‏2013-06-26T21:19:30Z

    Sounds like you want to read up on Control Break Logic. Apply this to your input type tree, which if structured properly can then feed into an output card functional map call placed in a (0:s) ranged cell.

    The code within the functional map will of course be a simple PUT statement.

    Hi Tarun,

    Do you have any sample or reference doc for control break logic.

     

     

     

  • Bhoju
    Bhoju
    37 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-09-10T13:20:37Z  
    • mahesh15
    • ‏2013-06-27T09:16:39Z

    Hi Tarun,

    Do you have any sample or reference doc for control break logic.

     

     

     

    Read the entire file in one input card of your executable map. From output card call a functional map and pass the row from input (The functional map will process one row at a time which is passed to it). From The functional map call another executable map which can read the same file from file system. In the second executable map write a rule to check if the data passed by functional map (single row) is matching with rest of the records in the file which is read by second executable map, if found take the count and write that many times the record into separate file (May be you can create the filename dynamically)..

    This is best i can suggest.

  • paul.brett
    paul.brett
    479 Posts

    Re: How to generate seperate files based on a condition

    ‏2013-10-09T08:17:19Z  

    A working example

    Attachments