# Writing to file in csv format from input text in dashboard

**URL:** <https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, database\
**Created:** [2 January 2022 18:48 UTC](https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007 "2022-01-02T18:48:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![imanipourmeysam](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@imanipourmeysam](https://discourse.nodered.org/u/imanipourmeysam)\
**Post date:** [2 January 2022 18:48 UTC](https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007/1 "2022-01-02T18:48:12Z")

</div>

Hello,  
I am trying to make a flow that write the input texts in the dashboard to a file with csv format.  
I am new to programming and I made this flow :

```auto
type or paste code here

```

I don't know how I can manage the msg.payload of the three input text in dashboard and save them in a file or append them to an existing file.  
[asdf.json](https://discourse.nodered.org/uploads/short-url/cPLcDpDx71ONYqcw4DMTt0V5KDI.json) (4.8 KB)

the file should be for example like this shape :  
name1,familyname1,age1  
name2,familyname2,age2  
name3,familyname3,age3  
and so on.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 January 2022 19:22 UTC](https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007/2 "2022-01-02T19:22:13Z")

</div>

Why not use the ui-form node, it would be simpler and have more control on input fields and when it is submitted.  
e.g.

```auto
[{"id":"365a165c.a92272","type":"change","z":"f8ec99b33c203710","name":"","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":155,"y":180,"wires":[["1023f232.58f71e"]],"l":false},{"id":"1023f232.58f71e","type":"ui_form","z":"f8ec99b33c203710","name":"","label":"","group":"6e33f3db.defabc","order":16,"width":0,"height":0,"options":[{"label":"Name","value":"name","type":"text","required":true,"rows":null},{"label":"Family Name","value":"family","type":"text","required":true,"rows":null},{"label":"Age","value":"age","type":"number","required":true,"rows":null}],"formValue":{"name":"","family":"","age":""},"payload":"","submit":"submit","cancel":"cancel","topic":"topic","topicType":"msg","splitLayout":"","x":250,"y":180,"wires":[["a1a2482b.6b99c","365a165c.a92272"]]},{"id":"a1a2482b.6b99c","type":"template","z":"f8ec99b33c203710","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{payload.name}}},{{{payload.family}}},{{{payload.age}}}","output":"str","x":480,"y":180,"wires":[["f83d4a7d53ad6e7c","cf435aea.907718"]]},{"id":"f83d4a7d53ad6e7c","type":"debug","z":"f8ec99b33c203710","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":180,"wires":[]},{"id":"cf435aea.907718","type":"file","z":"f8ec99b33c203710","name":"","filename":"/path/to/file.ext","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":630,"y":260,"wires":[[]]},{"id":"6e33f3db.defabc","type":"ui_group","name":"problems","tab":"8f03e639.85956","order":4,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<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:** [2 January 2022 19:26 UTC](https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007/3 "2022-01-02T19:26:25Z")

</div>

Hi @imanipourmeysam

This is the flow in your asdf.json file:

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/feb96038226f24753e3351b2268ceafbc7a42f47.jpeg)

Imagine that the user types into the "name" field. The payload will flow to the csv node and on to the file node, but there is no value for "age" and "last name".

You need to wait until all three input fields have a value before processing.  
One way to do that is with a Join node:

 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be16d95b06af58c9793affe288d5c282bd21e838.jpeg)

Notice that the Join node settings have "using the value of msg.topic as the key".  
You have to set a unique msg.topic in each input node.

Use debug nodes to see the outputs of the Join and csv nodes.

---

<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:** [1 February 2022 19:26 UTC](https://discourse.nodered.org/t/writing-to-file-in-csv-format-from-input-text-in-dashboard/56007/4 "2022-02-01T19:26:50Z")

</div>

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