# Feature request: read file, set msg.complete to true for last line

**URL:** <https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225>\
**Category:** Feature Requests\
**Created:** [3 July 2024 12:27 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225 "2024-07-03T12:27:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![evdheuvelUpl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/evdheuvelupl/32/68644_2.png) [@evdheuvelUpl](https://discourse.nodered.org/u/evdheuvelUpl)\
**Post date:** [3 July 2024 12:27 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/1 "2024-07-03T12:27:39Z")

</div>

When processing text files via the read file node, where it outputs a msg per line, it would be convenient when msg.complete is set to true for the last line. This makes it easier to group lines using the join node without having to add logic in a function node. This would harmonize the behaviour with that of nodes such as the csv node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f3b782c69a72b241fb262deb898780a37eb4bc8d.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 July 2024 13:59 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/2 "2024-07-03T13:59:48Z")

</div>

That sounds sensible.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 July 2024 15:43 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/3 "2024-07-03T15:43:12Z")

</div>

why not use the join node in auto mode ? It should recognise that the count is set at the end of the file and trigger the join also.

---

<div class="post-metadata">

**Author:** ![evdheuvelUpl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/evdheuvelupl/32/68644_2.png) [@evdheuvelUpl](https://discourse.nodered.org/u/evdheuvelUpl)\
**Post date:** [4 July 2024 09:47 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/4 "2024-07-04T09:47:28Z")

</div>

Thanks for pointing that out. I ran a quick test, when running the join node in auto mode I cannot set the "Send the message after a number of message parts". My goal is to create batches based on a set number of messages.

I also tried it with the batch node, but this doesn't respond to count nor complete. Example: my text files contains 12 lines. I set the batch node to group by 5 messages. This results in two batches of 5 lines, the last two 2 lines are not processed. I'm looking for three batches (messages) of 5, 5 and 2 lines respectively.

Perhaps I'm looking for two improvements:

- read file; set complete for the last line, this allows the join node to create the 3 messages.
- batch node; respond to complete to write out the remaining 2 lines.

Of course, tasks can be accomplished today using the function node in conjunction with the join node. However, it might also be beneficial to consider handling this intuitively within the batch node.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [4 July 2024 10:34 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/5 "2024-07-04T10:34:39Z")

</div>

Assuming you have one message per line of the file, a join node in manual set to 5 message parts **and** a timeout seems to work.  
I guess you would need a rate limit node to ensure 1 second delay between files.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/158c122fb1f7861de6dc63aef5bc16538d9ba754.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b205fb27e7cf2835d5e0aa956e6be53ca7a30834.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 July 2024 11:36 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/6 "2024-07-04T11:36:20Z")

</div>

I can see what you mean. I think it would make sense to enhance the batch node to optionally respond to the count / end of file.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 July 2024 14:13 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/7 "2024-07-04T14:13:59Z")

</div>

Created a Pull Request here - [Let batch node terminate "early" if msg.parts set to end of sequence by dceejay · Pull Request #4829 · node-red/node-red · GitHub](https://github.com/node-red/node-red/pull/4829) to add to batch node...

Sadly we have just released 4.0 so may have to wait until 4.1... as it's a new feature.

But of course you can copy the changes locally if you want, in the meantime.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 October 2024 14:14 UTC](https://discourse.nodered.org/t/feature-request-read-file-set-msg-complete-to-true-for-last-line/89225/8 "2024-10-02T14:14:08Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
