Export from Tinderbox to CSV


(Andreas Grimm) #1

Is there a way of exporting Tinderbox data to CSV just as easily as one can import CSV into Tinderbox?

It‘s important to export the Attributes as Column-Headers.

Ideas?
Cheers!


(Mark Anderson) #2

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:

Heading1,Heading2,Heading3
^children("csv-item")^

The template ‘csv-wrapper’ is then applied to the parent container of the notes being exported. The recursing template ‘csv-item’ uses this code:

^value($Heading1)^,^value($Heading2)^,^value($Heading2)^
^children("csv-item")^

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.


(Andreas Grimm) #3

Thank you, @mwra! I’ll play with it and report back.


How to structure a problem