# Bug in CSV node?

**URL:** <https://discourse.nodered.org/t/bug-in-csv-node/82297>\
**Category:** General\
**Created:** [24 October 2023 10:33 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297 "2023-10-24T10:33:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw\_te\_r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jw_te_r/32/69700_2.png) [@jw\_te\_r](https://discourse.nodered.org/u/jw_te_r)\
**Post date:** [24 October 2023 10:33 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/1 "2023-10-24T10:33:12Z")

</div>

Hi all,  
I read several sensors, and put the readings into an SQL file. With one measurement every 10 minutes, I should get some 52000 records per year.  
I'm trying to output those readings via an SQL query to a CSV file using the CSV node.  
I entered the column names in the 'Columns' property, and set 'Output' to 'Output once, until msg.reset'.  
In my first tests it worked beautifully. However, when testing with more records I noticed the column headers are missing.  
If I reduce the number of records with 'LIMIT ' I always get the headers back, even if 'LIMIT' is larger than the number of records.

Any thoughts?

---

<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:** [24 October 2023 10:54 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/2 "2023-10-24T10:54:41Z")

</div>

Can you create a simple flow to demonstrate the problem please? Use an Inject node to inject a small dataset as produced by the database. You can get that by feeding it into a debug node and using the Copy Value button then paste it into a debug node in `{}` mode. Keep it down to just a few records obviously.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 October 2023 11:07 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/3 "2023-10-24T11:07:48Z")

</div>

if you set ...until msg.reset then indeed the headers are only sent once.... until you send msg.reset...

so yes please to an example showing what you mean.

---

<div class="post-metadata">

**Author:** ![jw\_te\_r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jw_te_r/32/69700_2.png) [@jw\_te\_r](https://discourse.nodered.org/u/jw_te_r)\
**Post date:** [24 October 2023 11:19 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/4 "2023-10-24T11:19:18Z")

</div>

Unfortunately I can't reproduce the problem with a small dataset. First time I noticed I had approximately 19000 records.  
The SQL query reads:  
SELECT (field names) FROM (database) \> WHERE `date` \>= (one year ago);

When I send the output to a csv node the headers are missing.

If I change my query to:  
SELECT (field names) FROM (database) \> WHERE `date` \>= (one year ago) LIMIT 20000;

I get my headers plus my 19000 records.

@dceejay I assumed msg.reset was activated when the node is ready.  
I want my CSV starting with one header line, and I assumed I did it the right way. Was I wrong?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 October 2023 11:39 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/5 "2023-10-24T11:39:37Z")

</div>

So yes the node is reset when you deploy  
(or you could explicitly sent a msg.reset before you do your query to test it.)  
And yes you did it the right way. You should get one set of headers only. But you would then need to reset before the next query.

---

<div class="post-metadata">

**Author:** ![jw\_te\_r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jw_te_r/32/69700_2.png) [@jw\_te\_r](https://discourse.nodered.org/u/jw_te_r)\
**Post date:** [24 October 2023 12:26 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/6 "2023-10-24T12:26:40Z")

</div>

Thanks, that did the trick.

Is there a maximum number of records that can be exported using the CSV node?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 October 2023 13:30 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/7 "2023-10-24T13:30:45Z")

</div>

Depends how you feed it.. If it is one result object then the limit will be linked to the amount of system memory available.

---

<div class="post-metadata">

**Author:** ![jw\_te\_r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jw_te_r/32/69700_2.png) [@jw\_te\_r](https://discourse.nodered.org/u/jw_te_r)\
**Post date:** [24 October 2023 14:09 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/8 "2023-10-24T14:09:52Z")

</div>

Ok, thanks. Good to know, but it won't be a problem in this case.

---

<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:** [7 November 2023 14:09 UTC](https://discourse.nodered.org/t/bug-in-csv-node/82297/9 "2023-11-07T14:09:57Z")

</div>

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