I am using "file in" to read the file and generating a message for line.
For moving the file from source folder to destination folder, I know I can use the "fs-ops-move" node.
Question: How can I wait until the last record (don't know how many records in the file before hand, nor I would like to know) is delivered as a message by the "file in" node and then move this file from source folder to destination folder?
Figured out. The "file in" node adds "complete" property and sets its value to "true" when the file processing is complete.
Connected "csv" node to "file in" node. The csv node emits one json message per line.
Connected "function" node to "csv" node. In this node, wrote following code:
if (msg.complete == null || msg.complete == false) {
return null; //stops the execution of following nodes
}
else {
node.warn("Message parts count is " + msg.parts.count);
node.warn("File finished processing: " + msg.topic);
//Added the path module to the Setup tab.
//Set the msg.topic to file path earlier
msg.file = path.parse(msg.topic).base;
return msg;
}
Connected "fs-ops-move" node to the "function" node. Set the source and destination folders. Set the source file name and destination file name to msg.file