# How to record data in csv and excel file

**URL:** https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379
**Category:** General
**Created:** [29 September 2022 10:03 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379 "2022-09-29T10:03:29Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [29 September 2022 10:03 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/1 "2022-09-29T10:03:30Z")

</div>

Hi,  
I want to record data first in csv file but when i am doing this it is not recording value after parser  
is there any way to direct record data to excel with timespan directly  
Thanks  
See pic for reference

 ![csv node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ada7986424c781b4870170ca1c8d4e48fd4da4c6.png)  
 ![csv result](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/034a2d6b31a273c2ed6bd42107d781f3d999aa43.png)  
 ![storage node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fef258d7286bf38f3776b1a361aeea63a0076686.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 September 2022 10:16 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/2 "2022-09-29T10:16:09Z")

</div>

As the help says...

> When converting to CSV, the columns template is used to identify which properties to extract from the object and in what order.

Since you set the CSV node columns as ...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/16ff83134d29af0867626468b5d0059afad9a6b5.png)

it is expecting you to feed it with data that looks like `{"frequency": 49.29, "Hz": 50}`

---

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [29 September 2022 11:02 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/3 "2022-09-29T11:02:17Z")

</div>

The value after parser is not getting but before parser it is recording values

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 September 2022 11:38 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/4 "2022-09-29T11:38:44Z")

</div>

that makes no sense nor does it help us to help you.

Additionally, please use the reply button on my comment (and NOT the reply button at the bottom of the thread) because I do NOT get a notification and do not know you have replied (to me)

---

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [30 September 2022 06:04 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/5 "2022-09-30T06:04:01Z")

</div>

Hi,  
I meant to say when i connect to point then csv file is getting data and saving to file  
but when i connect csv node to point 2 then it is not getting data and save to file

 ![csv data getting issue](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47cf024b4415bd7b642713ba78d4cb5be4031894.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 September 2022 09:50 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/6 "2022-09-30T09:50:15Z")

</div>

> [@aminulhaq](#):
>
> I meant to say when i connect to point then csv file is getting data and saving to file  
> but when i connect csv node to point 2 then it is not getting data and save to file

And that is because of what I said in my previous post...

> [@Steve-Mcl](#):
>
> Since you set the CSV node columns as ...  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/16ff83134d29af0867626468b5d0059afad9a6b5.png)
> 
> it is expecting you to feed it with data that looks like `{"frequency": 49.29, "Hz": 50}`

The fact it works by connecting to the modbus node is because that data is an `array` of 2 values and you have 2 entries in the column field.

SO - your options are depenedant on what you are trying to achieve. Do you want 1 value in the file or 2 values in the file?

If you simply want the value of `item2` - set the column field to `item2`

  

### The better solution...

A better solution is to do what I suggested in the previous thread...

> [@How to convert integer value coming from modbus to float value](https://discourse.nodered.org/t/how-to-convert-integer-value-coming-from-modbus-to-float-value/68273/18):
>
> If you are reading registers 240-241 AND registers 256-257 then I strongly recommend you read all registers from 240~257 in one MODBUS node and use the parser to pick out the values of interest. This has the following advantages....
> 
> 1. values are read at the same scan of the device (and are therefore consistent)
> 2. reading 1 modbus poll of 28 items is faster than 2 modbus polls. This will only get worse with each additional single read/poll.
> 3. Individual modbus comms lead to contention on the wire (and eventually timeouts - search the forum - covered many times)

> [@How to convert integer value coming from modbus to float value](https://discourse.nodered.org/t/how-to-convert-integer-value-coming-from-modbus-to-float-value/68273/21):
>
> Use the `offset` to access other bytes,
> 
> | MB address | Returns | offset byte |
> | --- | --- | --- |
> | 240 | 16 bit integer (2 bytes) | 0 |
> | 241 | 16 bit integer (2 bytes) | 2 |
> | 242 | 16 bit integer (2 bytes) | 4 |
> | 243 | 16 bit integer (2 bytes) | 6 |
> | 244 | 16 bit integer (2 bytes) | 8 |
> | 245 | 16 bit integer (2 bytes) | 10 |
> | 246 | 16 bit integer (2 bytes) | 12 |
> | 247 | 16 bit integer (2 bytes) | 14 |
> | 248 | 16 bit integer (2 bytes) | 16 |
> | 249 | 16 bit integer (2 bytes) | 18 |
> | 250 | 16 bit integer (2 bytes) | 20 |
> | 251 | 16 bit integer (2 bytes) | 22 |
> | 252 | 16 bit integer (2 bytes) | 24 |
> | 253 | 16 bit integer (2 bytes) | 26 |
> | 254 | 16 bit integer (2 bytes) | 28 |
> | 255 | 16 bit integer (2 bytes) | 30 |
> | 256 | 16 bit integer (2 bytes) | 32 |
> | 257 | 16 bit integer (2 bytes) | 34 |
> 
> e.g...
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f85547f7deb2cec523aec170c341142804cd67c.png)

If you do this and set the CSV column to `energy,voltage` then it will log both fields together with consistency (i.e. values read at the same point in time)

---

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [30 September 2022 10:01 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/7 "2022-09-30T10:01:52Z")

</div>

no i didn't use that setting which you said in parser see my setting in picture i wnat to store frequency and voltage value on seperate column  
 ![parser setting](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/15dc905537824b8fa22f908b8a4fe1ac4fdab2f4.png)

 ![csv result](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/034a2d6b31a273c2ed6bd42107d781f3d999aa43.png)  
 ![csv setting](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/85c1c78f5b19622e1080ea3b68bd2382655315b0.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 September 2022 10:14 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/8 "2022-09-30T10:14:56Z")

</div>

> [@aminulhaq](#):
>
> i wnat to store frequency and voltage value on seperate colum

If you want to store BOTH values you need BOTH values in a SINGLE message.

Setting the buffer parser as I have instructed several times will get BOTH values into 1 object - with well defined sensible names. That's why I suggested using the buffer-parser to pick both values from the data at once (as well as the consistency and reduced polling benefits).

What are you not understanding here?

---

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [30 September 2022 10:19 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/9 "2022-09-30T10:19:47Z")

</div>

I understood what you are trying to say but as i am in testing phase so i am now just trying to get one value that is frequency but after parsing it is not coming in file but showing correct value in debug window

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 September 2022 10:31 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/10 "2022-09-30T10:31:53Z")

</div>

> [@aminulhaq](#):
>
> but as i am in testing phase so i am now just trying to get one value that is frequency but after parsing it is not coming in file but showing correct value in debug window

ok, then change the CSV node column to match the payload property name. e.g. set the column field to `item1` (better still, change the buffer-parser named "`item1`" to "`Frequency`" and set the CSV column field to `Frequency`- either way, the `.propertyName` has to match something in the column field.

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

---

<div class="post-metadata">

### Author: ![aminulhaq](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@aminulhaq](https://discourse.nodered.org/u/aminulhaq)
#### Post date: [30 September 2022 10:39 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/11 "2022-09-30T10:39:53Z")

</div>

Thanks Steven once again  
Now i will open another querry because i want my data with time stamp and need excel file will need your help there  
Thanks

---

<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: [14 October 2022 10:40 UTC](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379/12 "2022-10-14T10:40:02Z")

</div>

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