Merge two subsequent rows in one file

Seven Stars

Merge two subsequent rows in one file

Hi,

 

I am trying to merge two subsequent rows into one row.

Is there any component that does it or could you please suggets appropriate logic to do so.

Thanks.


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

This is a derivation of the solution I proposed, so no problem.

My understanding is that you have one or many style 2 lines for 1 style 1 line.

In this case maybe the simplest approach is to restore the alternation style 1 / style 2 lines.

Or maybe I don't understand completly what you expect.

Anyway, I think now you can close the case (and open a new one if you want to ask how to restore the alternation).


TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

Hi,

Using tMap varaibles you are able to get simultaneously the current and the previous row of the same data flow.

Assume the input flow schema contains 1 field called "line", here is how to do what you expect in your tMap:

Capture.PNG

 

How it works:

-  rank variable is here to know if you are on an odd or even line

- currentLine is made of previousLine + input flow line

- previousLine receive input flow line

On output side, only if rank is even, currentLine variable is used to populate result field.

Hope this helps.


TRF
Seven Stars

Re: Merge two subsequent rows in one file

Thanks TRF,
This worked perfect,


just a clarification needed
How does tMap component knows that the row65.line which is used to output in variable previousLine is the earlier record and not the current one, since the same row65.line is used to append in the currentLine.

 Also if i change the position of the previousLine, then it shows a purple two way symbol, can u please tell me what does it signify.

Thanks in advance for clarifying the doubt.

 

I also came across uneven data as displayed in screenshot.

Could you please suggest on how can i get the desired output.

Thanks

 

 

Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

Hi,

tMap variables are affected in the order they appear in the tMap area.

So, in this case:

1- rank is computed

2- currentLine is affected with the value of previousLine (null for the 1rst line) + row65.line

3- row65.line is saved into previousLine 

 

Don't forget to mark your case as solved.

 


TRF
Seven Stars

Re: Merge two subsequent rows in one file

Thanks much !!
I am also facing another issue in merging the data, as seen in the screenshot Uneven_data_merge.
It would be great if you could suggest appropriate solution.
Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

The purple arrow indicate a variable (previousLine) is reused by an other variable defined later (currentLine).

It seems the arrow doesn't appear when you reuse a variable which is not yet defined (you are not supposed to do that, but now you it works fine).

 

I apologize for the mistake in my initial answer, I wrote odd instead or even.

Does this answer you las question?

If not, are you able to reformulate or translate in french?


TRF
Seven Stars

Re: Merge two subsequent rows in one file

Thanks,
Yes, I have got the answer for my question.
If i modify the position wherein it displays the purple Arrow, i dont get the desired output.
The solution provided by you initially is correct and solves my purpose, however now i encountered another problem after further analysis of the data which i have mentioned in the screenshot.
Can you please help me in resolving this.
Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

Can you clarify what is not conform to the expected result?

Give the input and output as text, not image if possible.


TRF
Seven Stars

Re: Merge two subsequent rows in one file

file with input and desired output is attached

Seven Stars

Re: Merge two subsequent rows in one file

Hi TRF,

 

I have designed a solutin which is working fine.

Could you check and let me know if this is generic one or not, since i have used certain data conditions to achieve it.

Or if you can suggest any other generic way to do it.

 

Note: In this solution i have aggregated one column from one row and other column from respective group row

 

Thanks

Forteen Stars TRF
Forteen Stars

Re: Merge two subsequent rows in one file

This is a derivation of the solution I proposed, so no problem.

My understanding is that you have one or many style 2 lines for 1 style 1 line.

In this case maybe the simplest approach is to restore the alternation style 1 / style 2 lines.

Or maybe I don't understand completly what you expect.

Anyway, I think now you can close the case (and open a new one if you want to ask how to restore the alternation).


TRF
Seven Stars

Re: Merge two subsequent rows in one file

Thanks
Yes, the initial clarification you shared helped me the get this solved.
However i would like to know the restore alternation approach, will raise a new topic.