read file and split data line by line into DB

One Star

read file and split data line by line into DB

I have a file :
FileType00000001~CustomerLoad~83e3ec9b-d824-48a5-8102-773b72ad8cca~20120717101648
#KeyDefinitionField~ImpGuid~RowId~FirstName~LastName~RsaId~PassportNumber~IfaNumber~HomeTelephone~WorkTelephone~MobileTelephone~Fax~EmailAddress
#KeyDefinitionField~ImpGuid~RowId~PolicyNumber~PolicyStatus~PolicyPremium
Customer00000001~~0~Nobongile~Langa~~~~~~~~
Policy0000000001~~0~402060005~I~99.00
Customer00000001~~1~Nobongile~Langa~~~~~~~~
Policy0000000001~~1~610473373~I~135.00
Customer00000001~~2~Nobongile~Mabunda~~~~~~~~
Policy0000000001~~2~403897536~I~99.00
Customer00000001~~3~Nobonile~August~~~~~~~~
I want to be ale to read line by line, check whether it is a Customer00000001 or Policy0000000001 and populate 2 different tables depending on what row i am in .
apologies still new to talend (java) .
regards
One Star

Re: read file and split data line by line into DB

HI
You might create a job as the following images.
Code in tExtractRegexFields
"^Policy0000000001"

or
"^Customer00000001"

Regards,
Pedro
One Star

Re: read file and split data line by line into DB

okay ... that is what i was looking for.
a final question ? the entire row is put in one column, must I write to a temp file and extract from that temp file into the DB (separating the tilde delimited values) or is there and easier way.
I aso suppose i need to do this in 2 cycle , one for Customer0000001 and one for Policy00000001.
Regards
One Star

Re: read file and split data line by line into DB

Hi
Yes. You need to create two subjobs for this.
tFileInputDelimited--main-->tExtractRegexFields--main-->tExtractPostionalFields--main-->Output
The tExtractPostionalFields can help you extract columns with fixed pattern.
Regards,
Pedro
One Star

Re: read file and split data line by line into DB

THANKS PEDRO
GREAT HELP !!!!!
One Star

Re: read file and split data line by line into DB

Hi,
You could also split the row by a tMap.
Create 2 output rows from one tMap where you filter the output on the substring Customer and Policy
this way you only need to parse your input file once.
Regards,
Arno