# 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:** 1
**Showing post:** 6

<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)

---

_[View the full topic](https://discourse.nodered.org/t/how-to-record-data-in-csv-and-excel-file/68379)._
