cancel
Showing results for 
Search instead for 
Did you mean: 

Single Flat File needs to slipt in to N files depending up on matched rows

Former Member
0 Kudos
83

Hi All,

I have a requirement like...my incoming file(single file) needs to be split into N files based on a number of rows matches to each other. (Rows are matched up on 5 fields)

my incoming file is like this .....

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

B,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

B,name8,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

I need to split this file and my ouput file should be like this

One File:

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

Second File:

B,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

Thrid File:

B,name8,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

Can anyone tell me how this can be achieved?

Thanks,

Rajeev.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can able to do this using message split concept.

Mapping:

Concat the five fieldsremovecontextSplitbyvalue(valuechange)--TargetNode.

In message mapping go to messages tag and change the occourance to 0-unbounded.

In the interface mapping also target message occourance to 0-unbounded.

In ID:

use enhanced interface determination.

Regards,

Prakasu.M

Former Member
0 Kudos

Hi prakasu,

I tried wiht your mapping suggestions but it doesnt work.

Example:

Name age gender Place

A 20 M HYD

B 20 F BOM

A 20 M BLR

key fileds are name and gender:

I did how you mentioned and the output in MM and IM test tab is as follow:

A 20 M HYDwhere I should get

One messge:

A 20 M HYD

A 20 M BLR

and second one as

B 20 F BOM

Do let me know where I am missing:

Thnaks

Rajeev

Former Member
0 Kudos

Hi,

It should work...can you give your source and target examble structure with sample data..

As you mentioned,

name and gender is key fields.

Map like below:

name---concat--Remove context--sort(Lexicographical(case insensitive),ascending)--
------------------------------------------------------Collapsecontext---------------Node.
   Gender--

name---concat--Remove context--sort(Lexicographical(case insensitive),ascending)--Node1.
   Gender--

name---concat--Remove context--sortbykey(Lexicographical(case insensitive),ascending)---
-----------------------------------------SplibyValue(Each)-----------------------------------------------TargetElement.
   Gender--
   Source field(Each field)---------------

You should use Sort by key for all the fields.

Above answer was the below sample structure,

<Target>

<Node>----


0-unbounded

<Node1>----


0-unbounded

<TargetElement1(name)>

<TargetElement(age)>

<TargetElement1(location)>

Regards,

Prakasu.M

Edited by: prakasu on May 21, 2009 6:51 PM

Edited by: prakasu on May 21, 2009 7:01 PM

Former Member
0 Kudos

Hi,

I have the following structure in the MM :

Messages 1..1

--- Messages1 1..1

-


MM_Test 0..Unbounded

-


Age 0..Unbounded

-


Gender 0..Unbounded

-


Name 0..Unbounded

Target structure is:

Messages 1..1

--- Messages1 1..1

-


MM_Test 0..Unbounded

-


Age 0..Unbounded

-


Gender 0..Unbounded

-


Name 0..Unbounded

As I understood from you the did the following mapping:

Message(Target)

Name -


>

Gender-----> Contact -


>Remove Context -> Sort>CollapseContexts>Message(Target)

Message1(Target)

Name -


>

Gender-----> Contact -


>Remove Context -> Sort-->Message1(Target)

MM_Test

MM_Test------>MM_Test

Age (Target)

Name -


>

Gender-----> Contact -


>Remove Context --->

Age -


> SortByKey--


>SplitByValue--->Age(Target)

Gender(Taget)

Name -


>

Gender-----> Contact -


>Remove Context --->

Gender--


> SortByKey
>SplitByValue
--->Gender(Target)

Name(Target)

Name -


>

Gender-----> Contact -


>Remove Context --->

Name--


> SortByKey
>SplitByValue
--->Name(Target)

Still I am unable to achieve what I need.

Example Data:

Name age gender Place

A 20 M HYD

B 20 F BOM

A 20 M BLR

key fileds are name and gender:

I did how you mentioned and the output in MM and IM test tab is as follow:

A 20 M HYD where I should get

One messge:

A 20 M HYD

A 20 M BLR

and second one as

B 20 F BOM

Thanks

Rajeev

Edited by: rajeev raj on May 21, 2009 4:05 PM

Former Member
0 Kudos

Hi,

No..Not like dat.You should have a structure like below.No need to map message and message1.

MM_Test 0..Unbounded 
      Details  0..Unbounded
            Age 0..1 
            Gender 0..1
            Name 0..1

Instead of mapping Message(Target) you need to map MM_Test and instead of Message1(Target) you need to map Details.

Map like below for the fields:

Age (Target)

Name -


>

Gender-----> Contact -


>Remove Context --->

Age -


>Remove Context > SortByKey


>SplitByValue--->Age(Target)

Gender(Taget)

Name -


>

Gender-----> Contact -


>Remove Context --->

Gender--


>Remove Context
> SortByKey

>SplitByValue
--->Gender(Target)

Name(Target)

Name -


>

Gender-----> Contact -


>Remove Context --->

Name--


> SortByKey
>SplitByValue
--->Name(Target)

Regards,

Prakasu.M

Former Member
0 Kudos

Hi,

I see only one message in the result of test tab but I need the 2 messages if the search criteria has identify two different rows.

Are there any weblinks or PDFs where I can have step by step of this scenario or any input how can I make it?

Thanks

Rajeev

Answers (2)

Answers (2)

Former Member
0 Kudos

One more way you can try is get the entire file as xml using standard File Content Conversion.

records 0....unbounded

name1 0..1

name2 0..1

........

.........

And then take this payload into a java mapping and split it within the mapping,

Former Member
0 Kudos

Hi,

Could you please let us know the unique key to differentiate the records.

Thanks,

Kiran.

Former Member
0 Kudos

HI Kiran,

For example lets have the first two colum are the key fields.

my incoming file is like this .....

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

A,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

B,name,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

B,name8,name2,name3,name4,name5,name6,name7,.....,.....,........,.....,.....

Thanks

Rajeev.