split string into rows

One Star

split string into rows

Hi to all.

I have a string field that I have to split into 4 substrings and save each substring into a database.
I have defind a piece of custom code that return a String[] but I don't know how to use it as row source for writing into my db table.


Someone could help me please?

Thanks in advance.


Gisella
Seventeen Stars

Re: split string into rows

hi,

perhaps it's depend on how you work with your data.

I like to use simple routines class to do the job if it's not possible with a componenent.

for exemple :
package routines;

public class Parser {
private String[] fields;
public Parser(String toParse){
this.fields = toParse.split(" ");
}

public int getNumberField(){
return this.fields.length;
}

public String getString(int position){
return this.fields[position];
}
}

and redirect each part of my string into different direction (file, DB, other)
For that purpose, I create a new instance of my class in a the map componenent and use adequat method.

I can easily modify my methods or add a new one (for exemple delete some character or replace latin caracter or anithing else) in a single place ad use them as I want in my differents componenets.

not sure that the best way , but work fine for my main goals.

Hope it help you
laurent
Six Stars

Re: split string into rows

bronzett wrote:
Hi to all.

I have a string field that I have to split into 4 substrings and save each substring into a database.
I have defind a piece of custom code that return a String[] but I don't know how to use it as row source for writing into my db table.


Someone could help me please?

Thanks in advance.


Gisella

there are standard components do do that, to split one in field in an arbitrary number, ie. tExtractRegexFields

hope it helps

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog