One Star

Job which creates 3 shapefiles from one according to a field

Hi,
I would like to know if it's possible with TOS to create 3 shapefiles from one.
I have one shapefile (with a point geometry) with a field "Type" which contains 3 string values : "Site", "Technology point" and "Technology room".
I would like to get 3 shapes with the same fields but one shape for each "Type".
I tried with the components tReplicate and tMap but I don't succeed to split the shapefile according to the "Type" field.
Thank you for your help.
Best regards
Nicolas

7 REPLIES
One Star

Re: Job which creates 3 shapefiles from one according to a field

Hi Nicolas,
Sure it's possible using a tMap component for filtering on your field "Type".
You just have to create three output in your tMap, respectively linked to your three shapefile output components...and duplicate the other fields according to your needs.
You will have to explain your filter condition in Java in the tMap, something like : "Site".equals(rowX.Type) ....
Cheers,
Mathieu
One Star

Re: Job which creates 3 shapefiles from one according to a field

I'm not sure to understand what I have to do.
For my "Site" output shape, I use a tMap component with for each field the following condition :
(("Site".equals(row1.NO_TYPE))? row1.the_geom : null
(obvisouly, I replaced the field row1.the_geom with the good field).
In the tMap output, I have the 132 lines of the input shape and I would like to get 14 lines (the number of "Site"). So, I used a tFilterRows where I keep the lines with a geometry not null.
It works but when I use this method to get the "Technology poin", TOS crashes.
I think there is a bette idea , but I don't know which one.
One Star

Re: Job which creates 3 shapefiles from one according to a field

In my opinion, you only need your input shapefile, a tMap and your three shapefile output.
No need for tFilter components as you can filter output rows into your tMap.
The only thing you have to do is to define your three conditions in the tMap, one per output :
"Site".equals(row1.NO_TYPE)
"Technology point".equals(row1.NO_TYPE)
"Technology room".equals(row1.NO_TYPE)
Then you can reproduce the same output schema for all of them, even filter column by modifying the output schema...whatever you want to get!
Mathieu
One Star

Re: Job which creates 3 shapefiles from one according to a field

I don't understand where I can filter my input data in the tMap component.
For each field in the "Site" output schema, I wrote " ("Site".equals(row1.NO_TYPE)) ? value : null "
If I want to use only the tMap component , I must write or "nest" several tests in the same line ? It doesn't seem really clear to understand the job.
I have another question : is it possible to join/merge 2 polylines with TOS ? I didn't find any component in the SDI to do that.
Thank you four your help.
Nicolas
One Star

Re: Job which creates 3 shapefiles from one according to a field

I would recommend you to read this tutorial on tMap .
It might help you to understand filtering using tMap, which BTW does not mean filter each incoming fields.
Mathieu
http://www.talendforge.org/tutorials/tutorial.php?language=english&idTuto=9
One Star

Re: Job which creates 3 shapefiles from one according to a field

Thanks but I don't succeed to read any tutorials, when I write my amil and click on "register now", I'm redirected on the Talend home page. If I try again to read the tutorial, I have the same issue.
It does'nt matter if I use 3 tFiler component, but I will try to improve the job later.
And about my other question, is it possible to join/merge to polyline with TOS ?
Community Manager

Re: Job which creates 3 shapefiles from one according to a field

Hi Nykelbors8825
For the access problem to Talend online tutorial, we have noticed this issue before and it has been fixed, right now, you can try the following way to resolve it, clear all caches and remove all cookies from your browser.
Let me know if you still have problem to access tutorial.
Shon
----------------------------------------------------------
Talend | Data Agility for Modern Business