The way I do this is using an AttributeCreator set to handle adjacent feature attributes and a conditional value like you can do in Excel.
If previous row does not exist, groupId = 1.
ElseIf row begins with 01, groupId = previous groupId + 1.
Else, groupId = previous groupId.
Sample workspace attached.
Hi @ruth_h , a possible way is:
Separate the text lines into ones starting with "01" and others with the Tester (Preserve Feature Order: Across Output Ports).
On the flow for the text lines starting with "01*", extract the second field ("19633154000", "17163059000" in your example), and then save it as a global variable with the VariableSetter.
On the other flow, retrieve the global variable with the VarialeRetriever.
The attached screenshot illustrates a data flow example, assuming that the second field is always 11 characters. Be aware that the Preserve Feature Order parameter in the Tester should be set to "Across Output Ports" in order to keep the order of the text lines to be processed.
Hi @ruth_h , a possible way is:
Separate the text lines into ones starting with "01" and others with the Tester (Preserve Feature Order: Across Output Ports).
On the flow for the text lines starting with "01*", extract the second field ("19633154000", "17163059000" in your example), and then save it as a global variable with the VariableSetter.
On the other flow, retrieve the global variable with the VarialeRetriever.
The attached screenshot illustrates a data flow example, assuming that the second field is always 11 characters. Be aware that the Preserve Feature Order parameter in the Tester should be set to "Across Output Ports" in order to keep the order of the text lines to be processed.
This is another approach, inspired by @nielsgerrits 's answer.
Hi both, thank you so much for your help. Still struggling though. takashi - I have done this. However although the variablesetter has the id in, the variable receiver shows nothing in the id field. Please can you advise? Many thanks.
Hi both, thank you so much for your help. Still struggling though. takashi - I have done this. However although the variablesetter has the id in, the variable receiver shows nothing in the id field. Please can you advise? Many thanks.
I think the unexpected result is a side effect of the Feature Caching function. Check the Feature Caching off, then try again.
Hi takashi, unfortunately that didn't make any difference. I am a fairly basic user of FME, but I was wondering in this method how would it know to connect the lines below the one starting 01 with the 01 line with the unique reference. I was hoping it would magically work (it didn't) but I have to confess I don't understand how it would! Thanks Ruth
Hi takashi, unfortunately that didn't make any difference. I am a fairly basic user of FME, but I was wondering in this method how would it know to connect the lines below the one starting 01 with the 01 line with the unique reference. I was hoping it would magically work (it didn't) but I have to confess I don't understand how it would! Thanks Ruth
That's strange. Can you please share your workspace here?
Hi there, Here is the workspace and test file. Many thanks
Thanks for sharing your workspace and sample data.
I ran your workspace and was able to get desired result shown in the screenshot. I think there is no problem.
That's great thanks. Really weird - I closed it and opened and ran again and working for me too! Maybe I hadn't switched of the cache properly even though I thought I had. Many thanks for you help. Much appreciated.
That's great thanks. Really weird - I closed it and opened and ran again and working for me too! Maybe I hadn't switched of the cache properly even though I thought I had. Many thanks for you help. Much appreciated.
Because I never want to depend on feature order preservation on separate flows I prefer @nielsgerrits solution. FME has become better in preserving the order but If something slows down one flow it will break functionality.
Hi there, thanks for the input - unfortunately I didn't quite understand how to implement the suggestion from nielsgerrits so I didn't try that one.
Hi there, thanks for the input - unfortunately I didn't quite understand how to implement the suggestion from nielsgerrits so I didn't try that one.
create the variable that will hold the 'group' number. It can be empty for now.
Than use a AttributeCreator and set the checkbox for Adjacent Feature Attributes.
Then look at the start of your line. If it starts with the indicator for "New Feature", which is 01 in your case. Add +1 to the 'group' number of the Prior Feature for the current feature. Else use the 'group' number for the current feature.
The conditional Settings:
The @Value(feature[-1].featureIndex) is only available with the checkbox checked.
By the way: you could use reply on someone to keep the conversation together.
Hi jkr_da - Thank you very much for that. I will give it a go.