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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to archive a file which is 90 days older than the run date passed during job run

Hi,

I will pass run date (format: yyyymmdd) during job run and i have to archive the files from a folder which are 90 days old from the run date which i have passed.

 

The files in the folder are of the format

 

abcdefgh.Dyyyymmdd. 

How can this be achieved

Labels (2)
25 Replies
TRF
Champion II
Champion II

No problem with empty files.
Probably something wrong elsewhere in your job (context variable, global variable and so on). Double check everything or share the whole job design with components settings.
Anonymous
Not applicable
Author

Hi,

Sharing the whole job design along with individual component setting as well as the context variables.

 

Thanks


archv_dsgn.docx
TRF
Champion II
Champion II

The problem is probably due to filenames.
In your initial post you were speaking about filenames like "ABCDEFGH.DyyyyMMdd" but in fact it seems there is an extension (based on your tFileList filemask which is "ABCDEFH.D*.gz").
So, change the tSetGlobalVar_2 expression with the following to remove the file extension:

(((String)globalMap.get("tFileList_2_CURRENT_FILE")).replaceAll("^.*\\.D", "")).replaceAll("\\.gz$", "")

Start with this correction but a more generic solution could be:

(((String)globalMap.get("tFileList_2_CURRENT_FILE")).replaceAll("^.*\\.D", "")).replaceAll("\\." + (String)globalMap.get("tFileList_2_CURRENT_FILEEXTENSION) + "$" , "")

In this case, if you change the extension or filemask into tFileList_1 you don't have to change anything into tFileList_2.

 

Anonymous
Not applicable
Author

Hi,

 

Thanks for your reply and sorry for the confusion created from my end.

 

Actually i wanted to archive the files wherein the extension is gz (which was the reason i had included  "ABCDEFH.D*.gz" in the filemask). for eg if i need to archive a file with name ABCDEFGH.DyyyyMMdd.gz.

 

 

Anonymous
Not applicable
Author

Hi,
The job has only 1 tfilelist compo.
The flow is like this:-
tsetglobalvar_1->onsubjobok->tfilelist->iterate->tsetglobalvar_2->if->tfilecopy.

Please let me know if this correct. If another tfilelist has to be included please let me know as i couldnt understand it.

TRF
Champion II
Champion II

2 things you could have found by yourself:

- for the "If" expression replace "<= 0" by "> 0"

- if you decide to use the generic solution for tSetGlobalVar_2, the correct syntax is:

(((String)globalMap.get("tFileList_2_CURRENT_FILE")).replaceAll("^.*\\.D", "")).replaceAll("\\." + (String)globalMap.get("tFileList_2_CURRENT_FILEEXTENSION") + "$" , "")

It works (tested).

 

Anonymous
Not applicable
Author

Hi,

 

Sorry ..i am new to this. i dont understand what the new tsetglobalvar_2 will do.

 

why is there a "$" when i have to remove the extension of .gz from my incoming file

TRF
Champion II
Champion II

tSetGlobalVar_2 is in charge to extract the date from the current filename. It uses 2 regex:
1- to remove everything from the beginning to ".D" (included)
2- to remove the extension ($ to say at the end of the filename in case of the same string would be present in the filename)
So, if you have something like "ABCDEF.D20180511.gz" the result will be "20180511".
Anonymous
Not applicable
Author

Hi,

 

Thanks for helping me understand.

 

in tfilelist_2 i had given context.sourcefilepath at directory and in filemask i had given context.filename.

 

is this where it goes wrong ?

TRF
Champion II
Champion II

If value of context.sourcefilepath is still /data/Archive/ and files are in this this folder, it's ok for this one.
if value of context.filename is still ABCDEFGH.D, change it for ABCDEFGH.D.*.gz or use context.filename + ".*.gz" for the tFileList file mask.
Also think about tell me what goes wrong (as I gave you a working solution).