# CSV node does not cope with quotes in property names. Bug or feature?

**URL:** https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027
**Category:** General
**Created:** [14 October 2022 12:45 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027 "2022-10-14T12:45:40Z")
**Posts on this page:** 6
**Page:** 1

<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: [14 October 2022 12:45 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/1 "2022-10-14T12:45:40Z")

</div>

If I pass an array of objects to the CSV node and ask it to generate headers then, if any of the properties include a single quote character, then it fails with errors like  
`Error: Invalid property expression: unexpected array expression at position 12`  
Is that expected? I note that it does not fail with double quotes.

Example flow:

```auto
[{"id":"0a117283c6ec0e9a","type":"inject","z":"c57d82f577bb37d5","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"a'a\":\"A1\",\"b\":\"B1\"},{\"a'a\":\"A2\",\"b\":\"B2\"}]","payloadType":"json","x":160,"y":460,"wires":[["e9b9c226cb22fc89"]]},{"id":"e9b9c226cb22fc89","type":"csv","z":"c57d82f577bb37d5","name":"","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":330,"y":460,"wires":[["8a79b816b21ebf6f"]]},{"id":"8a79b816b21ebf6f","type":"debug","z":"c57d82f577bb37d5","name":"debug 28","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":460,"wires":[]}]

```

**[Edit]** Node red 3.0.2, nodejs 16.17.1

---

<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: [14 October 2022 13:01 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/2 "2022-10-14T13:01:30Z")

</div>

Hard to review as an embedded flow. Could you please give a simplified example of the input CSV data? I'm fairly (but not entirely) sure I've processed a CSV with embedded single quote in the past.

But CSV's can be funny things depending on what app produced them.

---

<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: [14 October 2022 13:55 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/3 "2022-10-14T13:55:13Z")

</div>

The flow is just an inject node injecting

```auto
[
    {
        "a'a": "A1",
        "b": "B1"
    },
    {
        "a'a": "A2",
        "b": "B2"
    }
]

```

and a CSV node configured as

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e3b6f9f6e5daf99a0e4a3142fbf8600daf25231.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: [14 October 2022 16:16 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/4 "2022-10-14T16:16:36Z")

</div>

Ah, I misunderstood, I thought you were going the other way.

I also clearly didn't read the title properly either! I've dealt with input CSV's with quotes in the values but I've never come across any CSV's with quotes in the column names. That would be rare indeed since they probably wouldn't translate to other storage types such as SQL tables would they?

I can confirm that it appears to be an edge-case bug. I would raise as an issue on GitHub.

---

<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: [14 October 2022 20:56 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/5 "2022-10-14T20:56:35Z")

</div>

> [@TotallyInformation](#):
>
> I can confirm that it appears to be an edge-case bug

Thanks for checking it out. Issue submitted.

> <https://github.com/node-red/node-red/issues/3919>
>
> \### Current Behavior
> 
> If an array of objects is passed to the CSV node and it …is configured to generate headers then, if any of the properties includes a single quote character, then it fails with errors like
> Error: Invalid property expression: unexpected array expression at position 12
> 
> Confirmed by @TotallyInformation in https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027
> 
> \### Expected Behavior
> 
> It should not fail
> 
> \### Steps To Reproduce
> 
> Run the example flow below
> 
> \### Example flow
> 
> \`\`\`
> \[{"id":"0a117283c6ec0e9a","type":"inject","z":"c57d82f577bb37d5","name":"","props":\[{"p":"payload"},{"p":"topic","vt":"str"}\],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\[{\\"a'a\\":\\"A1\\",\\"b\\":\\"B1\\"},{\\"a'a\\":\\"A2\\",\\"b\\":\\"B2\\"}\]","payloadType":"json","x":160,"y":460,"wires":\[\["e9b9c226cb22fc89"\]\]},{"id":"e9b9c226cb22fc89","type":"csv","z":"c57d82f577bb37d5","name":"","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\\\n","temp":"","skip":"0","strings":true,"include\_empty\_strings":"","include\_null\_values":"","x":330,"y":460,"wires":\[\["8a79b816b21ebf6f"\]\]},{"id":"8a79b816b21ebf6f","type":"debug","z":"c57d82f577bb37d5","name":"debug 28","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":460,"wires":\[\]}\]\`\`\`
> \`\`\`
> 
> \### Environment
> 
> \- Node-RED version: 3.2.0
> \- Node.js version: 16.17.1
> \- npm version: 8.15.0
> \- Platform/OS: Ubuntu
> \- Browser: Chrome

---

<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: [13 December 2022 20:57 UTC](https://discourse.nodered.org/t/csv-node-does-not-cope-with-quotes-in-property-names-bug-or-feature/69027/6 "2022-12-13T20:57:18Z")

</div>

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