# Dynamic column name for csv data logging

**URL:** <https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199>\
**Category:** General\
**Tags:** node-red-dashboard, function-node, mqtt, csv\
**Created:** [7 February 2025 07:20 UTC](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199 "2025-02-07T07:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![syed\_najam1](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@syed\_najam1](https://discourse.nodered.org/u/syed_najam1)\
**Post date:** [7 February 2025 07:20 UTC](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199/1 "2025-02-07T07:20:39Z")

</div>

I am logging data for 12 sensors in a CSV file, where each sensor corresponds to a specific column (e.g., Sensor1, Sensor2, Sensor3, etc.). I want to dynamically assign column names for each sensor through text input. While I have implemented the logic, the sensor data is mixing up with data from other sensors. Could you review my logic and provide suggestions to correct this issue?

 ![Dashboard](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/53ca549bd764a20ce4c7055481b0b0e07cac4fb7.png)  
 ![CSV](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/23b25492e61b7743340bbdeb8b6aa36dd2a9dc58.png)

please find the flow file in attachment

[flows.json](https://discourse.nodered.org/uploads/short-url/o7uxzSUfAKmVG8GSNsMVoMS9cgK.json) (16.0 KB)

---

<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:** [7 February 2025 09:57 UTC](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199/2 "2025-02-07T09:57:44Z")

</div>

Your flow looks overly complicated.

It would be best to keep the sensor csv as `timestamp,sensor1,sensor2.....`  
Then keep a separate cvs/lookuptable that maps the sensors to the dynamic column name/plant for displaying the cvs with the updated names.

I think you need to explain fully and clearly explkain how the data arrives and how it is logged. do you wait for all sensors etc before logging.

---

<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:** [8 May 2025 09:58 UTC](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199/3 "2025-05-08T09:58:00Z")

</div>

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