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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tFileArchive not working as expected

I have just observed a weird behavior of the tFileArchive component. If the name of the archive file's name contains a space followed by '(#)' where # is a number then the component does not create the archive file.

Below is the test job I have created

0683p000009LuH0.jpg

In this job I have context variables source_filename and destination_filename.

The destination_filename is set based on the source_filename as follows:

0683p000009Lu2P.jpg

Then the tFileArchive component's properties are set as follows:

0683p000009Lu84.jpg

Before the job is executed, if I set the name of the context variable source_filename as "archive.zip", then the destination zip file gets created correctly.

However if I set the source_filename as "archive (1).zip", the job executes successfully but no destination zip file is created. Also no error messages are generated.

Can anyone help me out with this issue?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Thanks @aranax your solution did not work but that did give me an idea which worked!

I used the following string in the filemask

"VC_" + context.source_filename.replace(".zip",".csv").replace("(","\\(").replace(")","\\)")

View solution in original post

6 Replies
cterenzi
Specialist
Specialist

You are using your source_filename context variable as part of your filemask.  If no files match the filemask, no archive is created.

Anonymous
Not applicable
Author

The file mask of tFileArchive is most likely considering the "(1)" as a regex and after evaluation is not able to find the file.

Anonymous
Not applicable
Author

Yes, this is exactly what is happening. Is there a way to tell Talend to ignore the "(" and ")" as special characters?

cterenzi
Specialist
Specialist

You would have to check the string for special characters and escape them.

 

Edit:

According to some searches, you can escape an entire string by wrapping it in \Q...\E.

e.g. "\\Q"+context.source_filename +"\\E"

 

Edit2:

I just tested this, and it doesn't work.

Anonymous
Not applicable
Author

I'm not very good at regex 

but

"CV_"+context.filename.replace(".zip","")+"\\([0-9]\\)"+".zip".replace(".zip",".csv") 

 

will work in the file mask

 

using proper regex  pattern it is possible to have the entire string inside a single string ,I'll look into it later if someone hasn't already replied

Anonymous
Not applicable
Author

Thanks @aranax your solution did not work but that did give me an idea which worked!

I used the following string in the filemask

"VC_" + context.source_filename.replace(".zip",".csv").replace("(","\\(").replace(")","\\)")