# Reading from CSV file insert values into influx-DB

**URL:** <https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886>\
**Category:** General\
**Created:** [1 August 2022 15:15 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886 "2022-08-01T15:15:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [1 August 2022 15:15 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/1 "2022-08-01T15:15:36Z")

</div>

Hi  
i am very much new to Node-Red concept . we have emerson PLC -CPL410 which supports node-red and Influx-db. I try to read PLC Diagnostic data CSV file continuously and insert a data into influx-db one by one.

i could able to display in node.warn msg individual data but not quite sure how to insert individual data into field like below

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e154d19305804bb19aa1b333bfbe0a5f2e0bc0b.png)

```auto
[{"id":"73e5e95c.050fe8","type":"csv","z":"711169bd.c68438","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":434,"y":312,"wires":[["27bdaada.685e9e","7f507812.bf37d8"]]},{"id":"9a9ed6a0.88d5b8","type":"inject","z":"711169bd.c68438","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":154,"y":312,"wires":[["f1b006d3.ab7888"]]},{"id":"f1b006d3.ab7888","type":"function","z":"711169bd.c68438","name":"","func":"data = `date,temperature\n202008110900,20\n202008111000,26\n202008111100,25\n202008111200,27\n202008111300,21\n`\nreturn {payload:data};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":312,"wires":[["73e5e95c.050fe8"]]},{"id":"9916d5e5.46f21","type":"debug","z":"711169bd.c68438","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":838,"y":312,"wires":[]},{"id":"27bdaada.685e9e","type":"switch","z":"711169bd.c68438","name":"Temperature > 25 ?","property":"payload.temperature","propertyType":"msg","rules":[{"t":"gt","v":"25","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":618,"y":312,"wires":[["9916d5e5.46f21"]]},{"id":"7f507812.bf37d8","type":"debug","z":"711169bd.c68438","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":578,"y":240,"wires":[]}]

```

---

<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:** [1 August 2022 20:58 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/2 "2022-08-01T20:58:41Z")

</div>

Welcome to the forum @Ferdi84

Show us what the data coming out of the csv node looks like in a debug node.

---

<div class="post-metadata">

**Author:** ![grant1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/grant1/32/49890_2.png) [@grant1](https://discourse.nodered.org/u/grant1)\
**Post date:** [2 August 2022 02:11 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/3 "2022-08-02T02:11:05Z")

</div>

Can you also provide details about your existing InfluxDB (version, if using InfluxQL or Flux, etc.)?

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 02:18 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/4 "2022-08-02T02:18:00Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8b17d1cbf6872a19bc10fd43656630fe445b99f.png)

thanks for the reply . csv output in debug mode attached as image copy

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 02:31 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/5 "2022-08-02T02:31:01Z")

</div>

Hi  
influxdb Version 1.8.6, InlfuxQL

---

<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:** [2 August 2022 07:50 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/6 "2022-08-02T07:50:03Z")

</div>

Sorry, that is unreadable as a screenshot. In the debug window click on the top level object and two little buttons should appear at the right hand side. Hover over the right hand button and it should show Copy Value. Do that then paste it here, using the `</>` button above the forum text entry window when pasting it.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item and how to copy data from there.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 08:56 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/7 "2022-08-02T08:56:16Z")

</div>

```auto
{"PlcTime,CatalogNum,SerialNum,FwVer,BuildId,FreeBytesInPart,FreeBlksInPart,MaxFreeBlkSize,AllocBytesInPart,AllocBlksInPart,SystemHeapSize,SysHeapTotalBlks,SharedHeapAvail,SharedHeapLargeAlloc,SharedHeapUse,SrtpConn,MbusConn,LAN1MbufFree,LAN1MbufUse,LAN2MbufFree,LAN2MbufUse,LAN3MbufFree,LAN3MbufUse,LAN4MbufFree,LAN4MbufUse,EthP1Off,EthP2Off,EthP3Off,pktRate[LAN1],max_pkt_rate[LAN1],timestamp[LAN1],pktRate[LAN2],max_pkt_rate[LAN2],timestamp[LAN2],pktRate[LAN3],max_pkt_rate[LAN3],timestamp[LAN3],":"22-JUL-2022 14:30:57.0,IC695CPL410-AAAA,UFAR00A,10.15,EGX2,14432880,175,5845056,253994064,26222,268426944,26397,2091008,1048576,6144,0,0,1022,37987656,1023,261,1023,257,1200,585,0,0,0,2,2782,16-JUL-2022 06:24:26.0,0,0,01-JAN-1970 00:00:00.0,0,0,01-JAN-1970 00:00:00.0"}

```

sorry for the trouble

---

<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:** [2 August 2022 09:01 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/8 "2022-08-02T09:01:41Z")

</div>

What does it look like going into the csv node?

---

<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:** [2 August 2022 09:05 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/9 "2022-08-02T09:05:02Z")

</div>

I don't see how that can be coming out of the csv node in the example flow you posted.

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 09:38 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/10 "2022-08-02T09:38:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fddd35152a721d989615b4dfd7083f3eb828c4c9.png)

This is sample CSV file i m reading with column header and values ( Columns are till AK)

---

<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:** [2 August 2022 09:48 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/11 "2022-08-02T09:48:56Z")

</div>

So the flow you posted was irrelevant apparently.

Cut the file down to a couple of lines and show us what is going into the csv node, using a debug node as before.

Also show us how you have configured the csv node.

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 10:12 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/12 "2022-08-02T10:12:46Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/877670b95c5befc14e2191eb46c5fa6a52f8615b.png)

above is CSV node setting

read node below

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e024fec713395a15f3e8273fed1019e8782877a8.png)

input to CSV node through Read node  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9d3f903221adca19e04bb082df423c253ad12578.png)

CSV node output first object

```auto
{"PlcTime,CatalogNum,SerialNum,FwVer,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,":""}

```

```auto
CSV Node output 2nd object 
{"PlcTime,CatalogNum,SerialNum,FwVer,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,":"7/22/2022 14:30,IC695CPL410-AAAA,UFAR00A,10.15,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"}

```

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 10:17 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/13 "2022-08-02T10:17:22Z")

</div>

```auto
[{"id":"821ed147.a04a9","type":"tab","label":"Sensors","disabled":false,"info":""},{"id":"3c451f09.b059d","type":"function","z":"821ed147.a04a9","name":"Add Daily Readings","func":"var json=[];\nfor(var w in msg.payload){\nvar to=msg.payload[w]\nvar tosplit =to.split(\",\");\nfor(var i=0;i<tosplit.length;i++)\n{node.warn(tosplit[i])}}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":100,"wires":[["7ece2c18.fd9644"]]},{"id":"2cb9ad73.620162","type":"csv","z":"821ed147.a04a9","name":"","sep":"\\t","hdrin":true,"hdrout":"all","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":true,"include_null_values":true,"x":450,"y":80,"wires":[["993d9476.ae6ff8"]]},{"id":"5860de91.e0685","type":"file in","z":"821ed147.a04a9","name":"Read","filename":"/data/log2.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":290,"y":80,"wires":[["2cb9ad73.620162"]]},{"id":"fa7ecd1d.548a3","type":"inject","z":"821ed147.a04a9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":80,"wires":[["5860de91.e0685"]]},{"id":"993d9476.ae6ff8","type":"json","z":"821ed147.a04a9","name":"","property":"payload","action":"obj","pretty":false,"x":590,"y":80,"wires":[["3c451f09.b059d"]]},{"id":"7ece2c18.fd9644","type":"influxdb out","z":"821ed147.a04a9","influxdb":"10991be8.70c254","name":"Local DB Server","measurement":"LocalDB1","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1100,"y":100,"wires":[]},{"id":"10991be8.70c254","type":"influxdb","hostname":"172.18.0.9","port":"8086","protocol":"http","database":"LocalDB1","name":"LocalDBserver2","usetls":false,"tls":"ced18875.cf10b8","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"ced18875.cf10b8","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true}]

```

sorry mistakenly i posted another flow , this is flow i am trying to work out

---

<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:** [2 August 2022 10:40 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/15 "2022-08-02T10:40:11Z")

</div>

I want to see the _input_ to the csv node, as you see it in a debug node. Reduce the file down to two data lines (plus the header line) to make it easier to follow.

---

<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 August 2022 10:59 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/16 "2022-08-02T10:59:46Z")

</div>

Looks like your csv file is using comma as separator, but you have set csv node to tab.  
Also do not check empty strings and null values.

---

<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:** [2 August 2022 11:06 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/17 "2022-08-02T11:06:04Z")

</div>

> [@E1cid](#):
>
> your csv file is using comma as separator

Yes, I was hoping to get the OP to work that out for himself.

---

<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 August 2022 11:11 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/18 "2022-08-02T11:11:13Z")

</div>

Life's under no obligation to give us what we expect/hope/wish.

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 11:16 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/19 "2022-08-02T11:16:38Z")

</div>

input to CSV node

```auto
PlcTime,CatalogNum,SerialNum,FwVer
7/22/2022 14:30,IC695CPL410-AAAA,UFAR00A,10.15
7/22/2022 14:30,IC695CPL410-AAAA,UFAR00A,10.15
7/22/2022 14:30,IC695CPL410-AAAA,UFAR00A,10.15
7/22/2022 14:31,IC695CPL410-AAAA,UFAR00A,10.15

```

output from CSV node ( thanks for the Tip)

```auto
{"PlcTime":"7/22/2022 14:30","CatalogNum":"IC695CPL410-AAAA","SerialNum":"UFAR00A","FwVer":10.15}

```

---

<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:** [2 August 2022 11:27 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/20 "2022-08-02T11:27:07Z")

</div>

OK, that is much better. A couple of questions

1. What time zone is the timestamp? Hopefully it is in UTC, otherwise it will have to be converted to UTC as that is what Influxdb requires.

2. Which of those values do you want as tags and which as fields in the database.

3. Have you looked at the help text for the Influx Out to see what format you need the data?

---

<div class="post-metadata">

**Author:** ![Ferdi84](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@Ferdi84](https://discourse.nodered.org/u/Ferdi84)\
**Post date:** [2 August 2022 11:48 UTC](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886/21 "2022-08-02T11:48:56Z")

</div>

Hey thanks for the reply

1. TimeZone -IST ( Indian Standard Time) , UTC+5.30
2. Serial No- Tag and rest of them are fields
3. i was gone through the document in Influx-DB out

```auto

msg.payload = 
  {
    PlcTime: global.get("PLctime"),
    CatalogNum: global.get("CatalogNum"),
    SerialNum: global.get("SerialNum"),
    FwVer: global.get("FwVer")
}
return msg 

```

[Next page](https://discourse.nodered.org/t/reading-from-csv-file-insert-values-into-influx-db/65886.md?page=2)
