# SOLVED: CSV Nodes Creates Triple Quotations

**URL:** https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112
**Category:** General
**Created:** [27 June 2018 06:11 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112 "2018-06-27T06:11:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Coderkido](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coderkido/32/853_2.png) [@Coderkido](https://discourse.nodered.org/u/Coderkido)
#### Post date: [27 June 2018 06:11 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/1 "2018-06-27T06:11:42Z")

</div>

I need to store a value into CSV as “Value”, but when I add delimited quotations in a function node value, send through the csv node and store into a file, if I open the resulting file in Notepad I get “”“Value”"" but if I open in Excel it shows as “Value”.

I have tried a wide variety of ways, but with no success. I either get NO Quotations, or Triple Quotations. Single Quotations work, but are not suitable for this application (not my choice).

I have even tried:  
`var quotes = String.fromCharCode(34);`  
`formattedTime = quotes + formattedTime + quotes;`

Way to recreate:  
From a function node  
`var formattedTime = "12-10-14 12:30:00"`;  
`formattedTime = "\"" + formattedTime + "\"";`

Store the value in an array, send msg.payload through csv node and save to a file.

- [] Node-RED version: 0.18.7
- [] node.js version: 8.11.2
- [] npm version: 5.6.0
- [] Platform/OS: Ubuntu 18.04 LTS

---

<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: [27 June 2018 06:32 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/2 "2018-06-27T06:32:55Z")

</div>

Why do you need quotes ? CSV files are fine without them. You only need them if the value contains a comma, and the time string you have shown doesn’t…

---

<div class="post-metadata">

### Author: ![Coderkido](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coderkido/32/853_2.png) [@Coderkido](https://discourse.nodered.org/u/Coderkido)
#### Post date: [27 June 2018 06:34 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/3 "2018-06-27T06:34:25Z")

</div>

Yes, I agree. This isn’t a requirement I have control over.  
The main reason is the way the data is pushed into a database by another host. Which I have no control over.

---

<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: [27 June 2018 06:42 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/4 "2018-06-27T06:42:20Z")

</div>

If its a simple CSV then maybe use a template node to create the lines instead of CSV node ? Eg  
`"{{payload.time}}","{{payload.foo}}"`  
Etc and then to a file node

---

<div class="post-metadata">

### Author: ![Coderkido](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coderkido/32/853_2.png) [@Coderkido](https://discourse.nodered.org/u/Coderkido)
#### Post date: [27 June 2018 06:50 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/5 "2018-06-27T06:50:34Z")

</div>

Potentially I might have too. I have already started working on a function to do so.

The CSV is generated from a nested array of varying length, so it was convenient to have it build via the node.  
Hence the hope to continue using it.

---

<div class="post-metadata">

### Author: ![Coderkido](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coderkido/32/853_2.png) [@Coderkido](https://discourse.nodered.org/u/Coderkido)
#### Post date: [27 June 2018 07:01 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/6 "2018-06-27T07:01:00Z")

</div>

So I ditched the CSV node and used what I found here : [Converts a 2D array into a CSV file · GitHub](https://gist.github.com/yangshun/01b81762e8d30f0d7f8f)

For anyone else who needs to solve this problem in Node-Red:

> function arrayToCSV (twoDiArray) {  
> var csvRows = ;  
> for (var i = 0; i \< twoDiArray.length; ++i) {  
> for (var j = 0; j \< twoDiArray[i].length; ++j) {  
> twoDiArray[i][j] = twoDiArray[i][j]; // Handle elements that contain commas  
> }  
> csvRows.push(twoDiArray[i].join(','));  
> }
> 
> ```
> var csvString = csvRows.join('\r\n');
> return csvString;
> 
> ```
> 
> }

---

<div class="post-metadata">

### Author: ![Coderkido](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coderkido/32/853_2.png) [@Coderkido](https://discourse.nodered.org/u/Coderkido)
#### Post date: [27 June 2018 23:20 UTC](https://discourse.nodered.org/t/solved-csv-nodes-creates-triple-quotations/1112/7 "2018-06-27T23:20:03Z")

</div>

Also, this is only necessary if your target application doesn't support the CSV standard.

> <https://github.com/node-red/node-red/issues/1775>
