There is no single-button method to do this, but it isn’t hard to do.
First, for those not used to CSV, it isn’t a format that’s defined beyond comma-delimited column and line break delimited rows. Thus if you want to export $Text or strings containing line breaks or double-quotes you’ll need to escape those … and standards vary. Different apps have different presumptions about such edge cases.
That aid the simplest way is to use two templates that employ the envelope-letter method. Assuming we have attributes $Heading1, $Heading2 and $Heading3 we want to export—including column headings—the ‘envelope’ template ‘csv-wrapper’ has this code:
The template ‘csv-wrapper’ is then applied to the parent container of the notes being exported. The recursing template ‘csv-item’ uses this code:
The latter template doesn’t need to be applied directly to any note as it is set automatically when called from the context of the parent note.