# From Influx IN node to CSV-file problem

**URL:** <https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855>\
**Category:** General\
**Created:** [8 June 2021 11:31 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855 "2021-06-08T11:31:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [8 June 2021 11:31 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/1 "2021-06-08T11:31:56Z")

</div>

In a simple flow, data is read from an Influx Database with, in addition to the timestamp, only one field namely "luchtdruk". The data is converted to a CSV file but in that file there are extra quotes (image).

Can someone tell me why this isn't working?

```auto
[{"id":"f12f6f56.44f4d","type":"tab","label":"CSV Range Forum","disabled":false,"info":""},{"id":"9d9141a6.1b19d","type":"influxdb in","z":"f12f6f56.44f4d","influxdb":"92192c23.a0c2c","name":"Read from InfluxDB","query":"SELECT \"time\",\"luchtdruk\" FROM \"luchtdruk\" WHERE time > now() - 1h","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":310,"y":80,"wires":[["63535a51.f1eac4"]]},{"id":"fc96823.e15978","type":"inject","z":"f12f6f56.44f4d","name":"Inject","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["9d9141a6.1b19d"]]},{"id":"9bbfcc1.a59393","type":"debug","z":"f12f6f56.44f4d","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":80,"wires":[]},{"id":"63535a51.f1eac4","type":"csv","z":"f12f6f56.44f4d","name":"Generate CSV","sep":",","hdrin":false,"hdrout":"none","multi":"one","ret":"\\n","temp":"time,luchtdruk","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":520,"y":80,"wires":[["9bbfcc1.a59393"]]},{"id":"92192c23.a0c2c","type":"influxdb","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"luchtdruk","name":"Luchtdruk","usetls":false,"tls":"1e7c3760.240cb9","influxdbVersion":"1.x","url":"192.168.2.185:8086","rejectUnauthorized":false},{"id":"1e7c3760.240cb9","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true}]

```

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28b96160998043db0127b865e3b8c34acad30ce3.png)

![db](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c970f0c6625576122cbaa57b6e8a0ce95e910303.png)

![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/01601ad6590626b970f2006865e8df93bacbea29.png)

---

<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:** [8 June 2021 11:35 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/2 "2021-06-08T11:35:46Z")

</div>

Put a `debug` on the output of the `influx` node and show what is coming out

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [8 June 2021 11:43 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/3 "2021-06-08T11:43:49Z")

</div>

Thanks Paul, below the output:

 ![nr](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cfc898aba37d4c73f8a3b50abb10570500742d7d.png)

---

<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:** [8 June 2021 12:05 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/4 "2021-06-08T12:05:06Z")

</div>

interesting...when I setup asn inject to send the data, here is my result:  
 ![Screen Shot 2021-06-08 at 8.03.20 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/68fd40458c0ca5e488333373e4d16c08dc1607ff.png)

what is the influx schema for this?  
What version of NR?  
What platform?  
what version of the CSV node?

p.s. I'll be gone for an hour or so.

here is ny test flow:

```auto
[{"id":"f12f6f56.44f4d","type":"tab","label":"CSV Range Forum","disabled":false,"info":""},{"id":"fc96823.e15978","type":"inject","z":"f12f6f56.44f4d","name":"Inject","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"time\":\"2021-06-08T09:46:28.109Z\",\"luchtdruk\":11023.2},{\"time\":\"2021-06-08T10:01:29.438Z\",\"luchtdruk\":11023.2}]","payloadType":"json","x":150,"y":200,"wires":[["883b652f.4e99b","63535a51.f1eac4"]]},{"id":"9bbfcc1.a59393","type":"debug","z":"f12f6f56.44f4d","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":160,"wires":[]},{"id":"63535a51.f1eac4","type":"csv","z":"f12f6f56.44f4d","name":"Generate CSV","sep":",","hdrin":false,"hdrout":"none","multi":"one","ret":"\\n","temp":"time,luchtdruk","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":400,"y":160,"wires":[["9bbfcc1.a59393"]]},{"id":"883b652f.4e99b","type":"debug","z":"f12f6f56.44f4d","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":410,"y":240,"wires":[]},{"id":"efc11cbe.d6f288","type":"inject","z":"f12f6f56.44f4d","name":"Inject","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"time\":\"2021-06-08T09:46:28.109Z\",\"luchtdruk\":11023.2},{\"time\":\"2021-06-08T10:01:29.438Z\",\"luchtdruk\":11023.2}]","payloadType":"json","x":150,"y":100,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [8 June 2021 12:23 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/5 "2021-06-08T12:23:54Z")

</div>

Your test flow works here too, without the extra quotes. NodeRED is 1.3.4, the CSV-node shows 1.2 and running NodeRED on a RPI-4. Please see the image above for the InfluxDB info.

---

<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:** [8 June 2021 12:29 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/6 "2021-06-08T12:29:56Z")

</div>

Missed that (influx) - I’ll take a deeper look when I get back

---

<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:** [8 June 2021 19:27 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/7 "2021-06-08T19:27:42Z")

</div>

I've reproduced the problen and am going to look at the code. Someting is tickling my head about a similar situation not too long ago....but it might have been a different node.

---

<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:** [8 June 2021 23:52 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/8 "2021-06-08T23:52:39Z")

</div>

Hans,

Ok I know what is causing the issue. an Influx timestamp is stored in **nanoseconds** while a javascript timestamp is stored in **milliseconds**. The Influx node doesn't know what datatype it is and thinks it is an object and that is why things get messy.

If you divide the returned timestamp(s) by 1000 then Node-RED/(JavaScript)/the CSV node can handle it.

I've opened an issue on the nodes Github page if you want to follow it:

> <https://github.com/mblackstock/node-red-contrib-influxdb/issues/99>
>
> If you select some rows from influx so the timestamp is returned, it looks great… in a Debug node however if you pass it onto a CSV node it gets surrounded by three double quotes.
> 
> If you pass the data to a function node and do a 'typeof' on it, it shows up as an object. Would it be possible to divide the timestamps by 1000 so Node-RED would treat them as a timestamp?

When Node-red starts processing the

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [9 June 2021 07:00 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/9 "2021-06-09T07:00:40Z")

</div>

Thank you for your kind help, solved!

---

<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 June 2021 07:00 UTC](https://discourse.nodered.org/t/from-influx-in-node-to-csv-file-problem/46855/10 "2021-06-23T07:00:48Z")

</div>

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