Icon

Main - Check Folder every 5 Minutes

<p>A KNIME workflow to check if a file in a folder has changed and then call a sub-workflow</p><p></p><p>The workflow will run permanently and check every 5 minutes (you can adapt that) if there has been a change. The last modification date will be stored in a CSV file. If there is no change nothing will happen</p>

URL: Hub: Call Workflow in KNIME https://hub.knime.com/-/spaces/-/~-OjK8KaTPRdnoL_4/current-state/
URL: Medium: KNIME, Paths and Loops — Automate Everything https://medium.com/low-code-for-advanced-data-science/knime-paths-and-loops-automate-everything-213455788685
URL: Wait for a Change in Folder - KNIME Forum (82041) https://forum.knime.com/t/question-about-wait-node/82041/8?u=mlauber71
URL: use the Wait node to execute a database query at fixed times (execution workflow) https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/36?u=mlauber71
URL: Medium: KNIME Batch Processing on Windows and MacOS https://medium.com/low-code-for-advanced-data-science/knime-batch-processing-on-windows-and-macos-caacde067bd0
URL: KNIME Blog: How to Create Workflow & REST Services with KNIME https://www.knime.com/blog/call-workflow-service-REST
URL: Hub: Playing around with Call Workflow - main-workflow to "Call Workflow - Sub" with the new "KNIME Workflow Services" https://hub.knime.com/-/spaces/-/~-OjK8KaTPRdnoL_4/current-state/

Annotations and comments
  • A KNIME workflow to check if a file in a folder has changed and then call a sub-workflow The workflow will run permanently and check every 5 minutes (you can adapt that) if there has been a change. The last modification date will be stored in a CSV file. If there is no change nothing will happen https://forum.knime.com/t/question-about-wait-node/82041/8?u=mlauber71
  • This is what happens if the file has changed since the last run. In this case a sub-workflow is being called
  • Just make sure the RowID is unique
  • Initialize the tracker CSV file - once
  • Save the file (new) to simulate the change
  • ../data/tracker.csv
  • ../data/tracker.csv => register the latest run with the "Last modified date"
  • ../Sub - Workflow To be Called
  • context.workflow.parent-path
  • path.separator.system length_parent_path= length(column("context.workflow.parent-path")) substr(column("context.workflow.parent-path"), length_parent_path-1, 1)
  • => paths
  • create /data/ folder if it does not exist
  • context.workflow.absolute-path context.workflow.path context.workflow.name
  • context.workflow.data-path
  • data-path
  • path variables
  • Date&Time - Execute
  • year
  • if(isInfinite($$CURRENT_COLUMN$$),-9999 , $$CURRENT_COLUMN$$)
  • if($$CURRENT_COLUMN$$>=1.7976931348623157E308,99999998 , $$CURRENT_COLUMN$$)
  • if($$CURRENT_COLUMN$$<=-1.7976931348623157E308,-99999998 , $$CURRENT_COLUMN$$)
  • row_id
  • replace($$CURRENTCOLUMN$$, "'", "''")
  • var_my_file => the file which is to be tracked if it has changed
  • var_my_folder
  • check the meta information from your file
  • var_my_file_name "my_file"
  • var_my_workspace_path
  • var_stop_loop currently always = 0
  • if the last modification date is already in the "tracker.csv" file nothing changes
  • Make sure the RowID is unique every time
  • here a local connector could be a Sharepoint
  • Last modified date
  • var_my_file
  • var_stop_loop=1 since the variable is always 0 the loop will run indefinitely
  • var_parent_path Determine the name of the parent path on the local machine
  • var_stop_loop
  • 00:00:02 just to make the process visable => can later be removed
  • set the time how long the loop should wait until the next run 00:00:10 ten seconds

Nodes

Extensions

Links