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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get Files from FTP server to Local Machine

Dear all,
I got struck in one issue which is as follows:
Requirement:
1) Get text file from FTP server to Local Machine, if we get files then rename this file by yyyyMMdd+name of the file+OK.text
2) We need to delete those text file from local folder which are 1 month OLD.
Development:
1) I have used Tftpget component to get files from FTP server to Local Machine, but i am unable to RENAME it LIKE yyyyMMdd+name of the file+OK.text becase i am not able to provide path of this file(Local Machine path).If i give remote directory path in tftprename component then it work but it rename in FTP server which i dont want.i want to make change of name in LOCAL machine only.

2) Not yet done.
Can you please help me with step by step process ....pleaseeee...
Thanks & Regards
RSH
Labels (2)
16 Replies
Anonymous
Not applicable
Author

Hello Sabrina,
I am unable to attach snapshots ? not getting reason of attachment failure???
My log folder contains Files like 20130101_log_OK.txt it is in YYYYMMDD format.
Assume today is 1st of Feb 2013( 20130201) then my log folder should now have files prior to 1st jan 2013 (20130101)
Regards
RSH
Anonymous
Not applicable
Author

Hi,
I am unable to attach snapshots ? not getting reason of attachment failure???

For registered users, clicking on "post reply" (not through the quick post") and pay close attention on Limitation: 20 images per post, each image must be less then 1024x768 pixels and 200 KB, .png is preferred.
Are you looking for that?
Best regards
Sabrina
0683p000009MAzB.png 0683p000009MAhh.png
Anonymous
Not applicable
Author

Hello Sabrina,
Actually process is i have an folder called LOG_Folder in which every day 1 text file will be added by talend Job scheduler.
Now requirement is i have to DELETE text file which will be greater than one month OLD.
Example:
Today is 27/08/2013 so today my job will be run and i will have 1 log text file in log folder, but after adding this file i have to delete those text files which are old more than 1 months i.e. Files Before 27/07/2013.
Please guide me or provide me steps(snapshots) so i can proceed further..
Thanks & Regards
RSH
Anonymous
Not applicable
Author

Hi,
Sorry for delay!
You can design a dynamic file mask in tFileList to get the last month logs and then delete them together(I mean files belong to July but not Files Before27/07/2013, such as,31 files will be deleted which include July in their file name).
The job work flow should be:tjava-->onSubjobOk-->tFileList-->tFileDelete
The code part:
         
java.util.Calendar calendar = java.util.Calendar.getInstance(java.util.TimeZone.getDefault(),java.util.Locale.ENGLISH);
calendar.add(calendar.MONTH, -1);
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMM"); //$NON-NLS-1$
dateFormat.format(calendar.getTime());

globalMap.put("key", dateFormat.format(calendar.getTime()));
System.out.println(dateFormat.format(calendar.getTime()));

See my screenshots for details
Best regards
Sabrina
0683p000009MAqB.png 0683p000009MAzG.png 0683p000009MAqF.png
Anonymous
Not applicable
Author

Hello Sabrina,
Thankful for your efforts to help me. 0683p000009MACn.png 0683p000009MACn.png 0683p000009MACn.png
Just like to inform you, i do have 7 text files in my LOG folder
1) 20130727_log.txt
2) 20130728_log.txt
3) 20130729_log.txt
4) 20130730_log.txt
5) 20130731_log.txt
6) 20130826_log.txt
7) 20130827_log.txt
😎 20130828_log.txt
Our today date will be generated by Talenddate.getdate(yyyymmdd) and it will be stored in context.
(Suppose today is 20130828)
So if i run the job it should delete only 2 files like
1) 20130727_log.txt
2) 20130728_log.txt
because ( Systemdate - 1 month ) = 20130728 ,
but presently when i Run our job it DELETE following files:
1) 20130727_log.txt
2) 20130728_log.txt
3) 20130729_log.txt
4) 20130730_log.txt
5) 20130731_log.txt WHICH IS WRONG...
Please suggest what changes need to be done in CODE?
Can you please tell me what is this code: ((String)globalMap.get("key")) ?? i dint got by "ctrl+ Space"
Thanks in Advance... 0683p000009MACn.png 0683p000009MACn.png 0683p000009MACn.png
Regards
RSH
Anonymous
Not applicable
Author

Hi,
Can you please tell me what is this code: ((String)globalMap.get("key")) ?? i dint got by "ctrl+ Space"

It is "Global variables". From the code in java, you can get a date"201307".
I put the date into a "Global variables"((String)globalMap.put("key",date)) so that tFilelist can use "((String)globalMap.get("key",date)))" in file mask.
NOTE:"key" is just the name of Global variables and it is changeable.
So if i run the job it should delete only 2 files like
1) 20130727_log.txt
2) 20130728_log.txt
because ( Systemdate - 1 month ) = 20130728 ,
but presently when i Run our job it DELETE following files:
1) 20130727_log.txt
2) 20130728_log.txt
3) 20130729_log.txt
4) 20130730_log.txt
5) 20130731_log.txt WHICH IS WRONG...

It seems that you need a date field "20130701-20130728", I need make a investigation on it and will come back to you asap.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,
You can use use tFileCopy and check "Remove source file"(if you don't want the source file).
To make it clear, I have designed a demo job: tfilelist-->iterate-->tfilecopy
See my screenshot for details

Agreed!