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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to get file name dyanamically

Hi, Below are some of file names:
1)ut_full_load_rta_fast_1_23_20182312_1523.log
2)ut_fullload_first_extract_1_20183101_2356.log
3)ut_catload_dyanamic_overload_fan_2_20182107_1245.log
and so on

My required output in excel to get Table Names from above file names as below respectively:
1)rta_fast
2)first_extract
3)dyanamic_overload_fan

Can anyone help on this?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

replaceAll("ut_.*load_", "").replaceAll("_\\d{0,}_.*","");

 

try this

View solution in original post

5 Replies
TRF
Champion II
Champion II

I suppose you are using a tFileList, so the filename is associated to the variable tFileList_1_CURRENT_FILE. Using a regex you can get what you want for example into an other global variable:
globalMap.put("TableName", ((String) globalMap.get(tFileList_1_CURRENT_FILE).replaceAll("^ut_.*load_", "")).replaceAll ("_[0-9]_.*$", ""))
It's possible there is a syntax error, sorry I can try just now.
Hope this helps.
Anonymous
Not applicable
Author

Hi,

Thanks for Reply

I am getting perfect output but there are some other files which look like:

ut_load_fast_read_20181212_1524

 

Required Table Name : fast_read

Anonymous
Not applicable
Author

replaceAll("ut_.*load_", "").replaceAll("_\\d{0,}_.*","");

 

try this

Anonymous
Not applicable
Author

Hi,

Thanks for reply.

This Solution worked.

Can you please explain what does replaceAll("_\\d{0,}_.*","")  mean

 

Thanks,

Raj

Anonymous
Not applicable
Author

it replaces all substrings of type <_><any number of digits><_><anything after that> with <""> i.e. empty string.

 

 

 

regards

chandra kant