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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic FileName Change

Hi Team

 

I have a simple Scenario

Using tFileList  i am reading a list of files and converting them to excel formats

while doing this process i want target file name to same as source file name but with Excel extension

How can this be achived,

I am using Using "((String)globalMap.get("tFileList_1"))" to get the filname,but i am getting file name along with source extension.

I am attaching the screenshot here with

 

Please help me out how this can be done

 

Thanks in advance

Deepthi

Deepthi

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

You just need to use a tiny bit of Java. It is probably better to turn this into a routine so that your code doesn't look messy in your job, but this is how you would do without a routine....

 

((String)globalMap.get("tFileList_1")).substring(0,((String)globalMap.get("tFileList_1")).indexOf('.'))+".xls"

 

As a routine it might look like this......

public static String replaceFileExtension(String filename, String extension){
     String returnVal = filename;
     
    if(filename!=null && filename.indexOf('.')>-1){
           returnVal = filename.substring(0, filename.indexOf('.'))+"."+extension;
    }
    return returnVal;
}

You would use the above like below....

 

replaceFileExtension(((String)globalMap.get("tFileList_1")), "xls")

 

#I should point out that I have written this freehand so there may be a couple of tweaks required.

View solution in original post

1 Reply
Anonymous
Not applicable
Author

You just need to use a tiny bit of Java. It is probably better to turn this into a routine so that your code doesn't look messy in your job, but this is how you would do without a routine....

 

((String)globalMap.get("tFileList_1")).substring(0,((String)globalMap.get("tFileList_1")).indexOf('.'))+".xls"

 

As a routine it might look like this......

public static String replaceFileExtension(String filename, String extension){
     String returnVal = filename;
     
    if(filename!=null && filename.indexOf('.')>-1){
           returnVal = filename.substring(0, filename.indexOf('.'))+"."+extension;
    }
    return returnVal;
}

You would use the above like below....

 

replaceFileExtension(((String)globalMap.get("tFileList_1")), "xls")

 

#I should point out that I have written this freehand so there may be a couple of tweaks required.