<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to split a source field into 2 fields? in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302092#M74115</link>
    <description>Assume the input field is called myField, using a tMap you can do the following with the appropriate regex.&lt;BR /&gt;- for crmDesc: myField.replaceAll(":.*$", "")&lt;BR /&gt;- for crmID: myField.replaceAll("^.*:", "")&lt;BR /&gt;&lt;BR /&gt;Using a tJavaRow, you can also use the String.split() method.</description>
    <pubDate>Fri, 10 Aug 2018 22:47:55 GMT</pubDate>
    <dc:creator>TRF</dc:creator>
    <dc:date>2018-08-10T22:47:55Z</dc:date>
    <item>
      <title>How to split a source field into 2 fields?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302091#M74114</link>
      <description>&lt;P&gt;I have a CRM field as a source which I need to split into two.&amp;nbsp; Output is sql server.&lt;/P&gt;&lt;P&gt;Anything before : should load to crmDesc and anything after : should load to crmID&lt;/P&gt;&lt;P&gt;ABCDEFG:1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is a java syntax that I can use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 22:09:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302091#M74114</guid>
      <dc:creator>rp2018</dc:creator>
      <dc:date>2018-08-10T22:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a source field into 2 fields?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302092#M74115</link>
      <description>Assume the input field is called myField, using a tMap you can do the following with the appropriate regex.&lt;BR /&gt;- for crmDesc: myField.replaceAll(":.*$", "")&lt;BR /&gt;- for crmID: myField.replaceAll("^.*:", "")&lt;BR /&gt;&lt;BR /&gt;Using a tJavaRow, you can also use the String.split() method.</description>
      <pubDate>Fri, 10 Aug 2018 22:47:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302092#M74115</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2018-08-10T22:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a source field into 2 fields?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302093#M74116</link>
      <description>&lt;P&gt;Can you please give me a syntax how to do this in Java.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 15:21:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302093#M74116</guid>
      <dc:creator>rp2018</dc:creator>
      <dc:date>2018-08-13T15:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a source field into 2 fields?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302094#M74117</link>
      <description>&lt;P&gt;To use the String.split() method in a tJavaRow, first create your output columns. I have assumed you will use "crmDesc" and "crmID". Then (assuming your input data column is "myField") your code would look like below...&lt;/P&gt;
&lt;PRE&gt;//Code generated according to input schema and output schema
String[] fields = input_row.myField!=null ? input_row.myField.split(":") : new String[0];


if(fields.length==2){
	output_row.crmDesc = fields[0];
	output_row.crmID = fields[1];
}else if(fields.length==1){
	output_row.crmDesc = fields[0];
	output_row.crmID = "";
}else{
	output_row.crmDesc = "";
	output_row.crmID = "";
}&lt;/PRE&gt;
&lt;P&gt;I've covered scenarios where your input data is null, doesn't contain a ":" (I've assumed the data should go to the "crmDesc" column in that scenario), is as you expect and if more than 1 ":" character appears (it outputs blank fields for that). You can obviously adjust to your requirements.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 17:23:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-split-a-source-field-into-2-fields/m-p/2302094#M74117</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-13T17:23:35Z</dc:date>
    </item>
  </channel>
</rss>

