Six Stars

how to read file pattern and length of the file pattern dynamically

Hi Team,

 

may i know any idea below logic.

 

I have files i want to read file pattern and length of the file pattern dynamically.

 

Let say.

 

AAA_date_timestamp.csv

 

I want to read file pattern AAA and length of the pattern is 3. 

 

Note: AAA and 3 read dynamically from file or database. The Pattern and length will change before job start.

 

I have written code in tjava and routine. PFA code.

 

Thanks

Shree

 

2 REPLIES
Moderator

Re: how to read file pattern and length of the file pattern dynamically

Hello,

You can extract name and extension use the java methode on the object substring(start_indext,lenght). If you know that the file name will contain an underscore and you want to pull anything before that

For example:
Context.filepath = CurrentFile.substring(0,StringHandling.INDEX(CurrentFile,"-")).

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: how to read file pattern and length of the file pattern dynamically

Hi Sabira,

 

I think little confusion on requirement i think.

 

Let's say my file name is:  AAA_001_timesatmp.csv

 

I want to read the file name which file pattern is AAA and length(0,3). Now job is completed. 

Before if want to run next time, need to change file pattern and length of file pattern dynamically. 

 

PATTERN:001 and length(4,6).

 

I want to set this pattern dynamically outside talend jobs and read from values from file/database dynamically.

 

Please let me know if you need  more information.

 

Thanks

Shree