# How can I write CSV file and change filename with name list in array

**URL:** <https://discourse.nodered.org/t/how-can-i-write-csv-file-and-change-filename-with-name-list-in-array/68127>\
**Category:** General\
**Created:** [23 September 2022 10:22 UTC](https://discourse.nodered.org/t/how-can-i-write-csv-file-and-change-filename-with-name-list-in-array/68127 "2022-09-23T10:22:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [23 September 2022 11:24 UTC](https://discourse.nodered.org/t/how-can-i-write-csv-file-and-change-filename-with-name-list-in-array/68127/2 "2022-09-23T11:24:03Z")

</div>

try this solution with necessary modification

> [@Generate a PDF-file with variable filename](https://discourse.nodered.org/t/generate-a-pdf-file-with-variable-filename/64228/2):
>
> remove the hard coded filename from the file node & in your function add something like... // your code const reportDate = new Date().toISOString().replace(/[TG]/g,'\_').replace(/:/g,'-').substring(0,19); const reportName = 'mydata' msg.filename = `c/reports/report-${reportName}-${reportDate}.pdf` return msg;

---

_[View the full topic](https://discourse.nodered.org/t/how-can-i-write-csv-file-and-change-filename-with-name-list-in-array/68127)._
