# Create and download a CSV file

**URL:** <https://discourse.nodered.org/t/create-and-download-a-csv-file/39485>\
**Category:** General\
**Created:** [21 January 2021 11:22 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485 "2021-01-21T11:22:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LucaCarminati](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@LucaCarminati](https://discourse.nodered.org/u/LucaCarminati)\
**Post date:** [21 January 2021 11:22 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485/1 "2021-01-21T11:22:35Z")

</div>

Hi to all,

I am trying to create a CSV file from a UI\_Form present in the UI.  
I have tryed and modify a lot of example find in the web and in the forum, but no one works like I think.  
I'd like that there should be a "Download" button in the ui and when I have pressed the Send botton of the ui\_form (so I have confirmed what I have written) then in any moment I can press the Download button and Create and Download a CSV file with inside the data that I have put in the ui\_form.

The goal should be this :

- Write some parameters in the ui\_form (for example ten parameter) and press Send
- Press the button "Download" that allows to create a CSV file with the ui\_form parameter

Here there is another things that I don't understand...In all the example that I have seen, you need to specify the path for downlad the CSV file.  
But I think that, well, Node-Red works on a browser like Chrome, Edge etc.. where from the installation of the latter there is already a specified path to download a file from the internet, that is for most of us the Download folder.  
So, is there a method for take automatically the download path from the browser? I think that this should be very handy also for move a Flow from a PC to another.. you need only to copy and paste the flow and then it takes automatically from the browser that is in use the Download path.

Thanks to all!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 January 2021 11:52 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485/2 "2021-01-21T11:52:45Z")

</div>

Why do you want to make the user to have to press two buttons to actually send the data? Don't you realize that will lead to data never being added to the file? People will neglect to press the second button (human nature). I can see pressing the "Send" button and having a pop-up asking if they really want to add the data to the file, but not having two seperate buttons actions.

Or maybe I'm confused and you want the 'Send' button to actually write to the file on the server running NR and the 'Download' button to fetch the file from the NR server and store it on device running the dashboard.

---

<div class="post-metadata">

**Author:** ![LucaCarminati](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@LucaCarminati](https://discourse.nodered.org/u/LucaCarminati)\
**Post date:** [21 January 2021 12:01 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485/3 "2021-01-21T12:01:16Z")

</div>

Hi @zenofmud ,

Thanks for the reply.

No well the final project is another.  
With the ui\_form I put some data that with a already developed node will be modified and sent in OPCUA to a PLC.  
The data that I put in the ui\_form will create a way; for example this could be a compiled ui\_form :

Start  
Station 1  
Station 2  
....  
End

So when I press the Send button I work with my flow and I send data to a PLC (that will move something).  
At the end, I want that the operator could Download (with the button Download), if he want, the way that he has written.  
Whit the CSV files downloaded, the operator can check all the route that he has done.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 January 2021 01:28 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485/4 "2021-01-22T01:28:28Z")

</div>

Ok, so you have a form that will have some data (doesn't matter what) and you will use it to create a row of values.

1. will this row of data be added to the end of the CSV file or overwrite it each time or will there be a new file for each submit?
2. will the `download` button be on the same page as the submit button?
3. If the browser gets refreshed, how will you identify the datafile to be downloaded?

If you think that each 'way' will be in a seperate file, then you will need to read the directory the file is in and present it to the user to select the one they want downloaded.

You might want to look at this flow in the Flow library: [Download a file from node-red using standard nodes](https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419). It might give you an idea of how you can download the file.

---

<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:** [23 March 2021 01:28 UTC](https://discourse.nodered.org/t/create-and-download-a-csv-file/39485/5 "2021-03-23T01:28:38Z")

</div>

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