# Receive csv from FTP and send it to MQTT

**URL:** <https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771>\
**Category:** Industrial\
**Created:** [9 October 2022 16:56 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771 "2022-10-09T16:56:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MVasconcelos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mvasconcelos/32/68917_2.png) [@MVasconcelos](https://discourse.nodered.org/u/MVasconcelos)\
**Post date:** [9 October 2022 16:56 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/1 "2022-10-09T16:56:08Z")

</div>

Hi,

We have a machine that sends a csv every 30 seconds with this data:  
Date,Time,speed  
2022/10/07,08:01:00,36

My goal is to create a Node-Red flow that reads the content of the file and then send it to MQTT. The only thing "that matters" is the speed. If I have a few seconds between the time in the csv and the time in the MQTT is not a problem.

The problem is that my knowledge in Node-Red is very basic. I tried to get the data from the FTP but with no luck. I think the goal will be using functions (I guess) but as I said I'm very limited at this point.

So, any help will be appreciated.  
Thank you

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 October 2022 19:01 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/2 "2022-10-09T19:01:11Z")

</div>

Are you trying to send just the latest speed or the complete contents of the file with many speed values?

---

<div class="post-metadata">

**Author:** ![MVasconcelos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mvasconcelos/32/68917_2.png) [@MVasconcelos](https://discourse.nodered.org/u/MVasconcelos)\
**Post date:** [10 October 2022 10:36 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/3 "2022-10-10T10:36:13Z")

</div>

send only the latest speed. After reading the value it needs to delete the file

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 October 2022 13:12 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/5 "2022-10-10T13:12:29Z")

</div>

Is reading the file via ftp the only way of accessing the data? Does the machine support modbus for example?

If you need to fetch it by ftp then first make sure you can do that using an FTP client on a PC. Then you should be able to do the same in node-red. I have not had much success with the FTP nodes though, so when I needed to do this I used Exec nodes to execute the required command line ftp commands.

---

<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:** [10 October 2022 14:38 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/6 "2022-10-10T14:38:11Z")

</div>

If you do end up using an exec node then I also suggest looking at the `lftp` command (on linux) which lets you get files in a single command

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 October 2022 14:59 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/7 "2022-10-10T14:59:08Z")

</div>

> [@dceejay](#):
>
> the `lftp` command (on linux)

I haven't come across that, I have used ftp\_get, but lftp looks much cleverer so I will try that next time I need it. Thanks.

---

<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:** [9 December 2022 14:59 UTC](https://discourse.nodered.org/t/receive-csv-from-ftp-and-send-it-to-mqtt/68771/8 "2022-12-09T14:59:43Z")

</div>

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