Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ben0109
Contributor III
Contributor III

Move file if date modified is newer

Hi

I am new to Qlikview, so what I "know" is from Google...

I have a couple of Excel documents with financial records for different entities. When a file is updated, the user will drop it in a folder (full path will is C:\Test\Current\May_2019_statements.xlsx). When the Qlikview database reloads, the file must be moved to the processed folder (full path will is C:\Test\Processed\May_2019_statements.xlsx).

The Excel files have a summary on Sheet1, clearly indicating the month, and total sales (Columns A1 and B1). My goal is for Qlikview to do the following:

1. Move file from Current folder to Processed folder, if the date modified is newer.

2. Update the records for the specific month in the Qlikview table.

This is what I have so far:

LET ProcessedPath = 'C:\Test\Processed';
LET CurrentPath = 'C:\Test\Current';
FOR each Dir in DirList "$(CurrentPath)"
        FOR each File in FileList "$(CurrentPath)\*.xl*"
                EXECUTE cmd.exe /C Move /Y "$(CurrentPath)\*.xl*" "$(UnreadPath)\";
        next File
next Dir

LOAD * INLINE [
A1, B1
Month Name, Month values
];

 

From the above, all that works is to move the file, although it replaces without notice and does not do any checks on the last modified dates.

Any help with be much appreciated.

1 Reply
Brett_Bleess
Former Employee
Former Employee

The INLINE load is the issue here, that requires you to give the values, you need to drop the INLINE and load from the Excel files, and I think you are going to need to concatenate things as well, but I am not sure, not a very good developer, sorry.  

Here is the link to Help on the Load statement, hopefully this will explain things a bit better, but you can also use the wizard in the desktop client to try to get a better idea of how the script statements should look by loading from one of the Excel files using the Wizard and then look at the code that generates and go from there.  Sorry I do not have anything better, but hopefully this may help you get things on track:

https://help.qlik.com/en-US/qlikview/November2018/Subsystems/Client/Content/QV_QlikView/Scripting/Sc...

Ah, I also wanted to mention a new feature in the 12.30 track, there is a new task type there, File Exists:

https://help.qlik.com/en-US/qlikview/November2018/Subsystems/QMC/Content/QV_QMC/QMC_System_Supportin...

Scroll down until you see the File Exists feature there, this might help you out some too, you could use tasks to do things, so when a new file comes in, process it in the load, then kick off another task to move that file from the incoming to the processed folder etc...

Hope this helps a little!

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.