Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
In this job I have context variables source_filename and destination_filename.
The destination_filename is set based on the source_filename as follows:
Then the tFileArchive component's properties are set as follows:
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?
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(")","\\)")
You are using your source_filename context variable as part of your filemask. If no files match the filemask, no archive is created.
The file mask of tFileArchive is most likely considering the "(1)" as a regex and after evaluation is not able to find the file.
Yes, this is exactly what is happening. Is there a way to tell Talend to ignore the "(" and ")" as special characters?
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.
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
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(")","\\)")