Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

 

Labels (3)
2 Replies
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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