Post-edit. Following Paul's update (last post above) I'm updating the templates to Tab-delim format. I've moved the CSV stuff to a new post (next one below) as it might be of general use in exporting CSV data.For those less familiar with export, here's the TB end. OK, some assumptions:
- Export will happen via an agent
- The tags are stored in a user Set-type attribute $TagSet. Use a set rather than a List so the per-item values are always de-duped (i.e. a given tag doesn't appear more than once in any given item's TagSet)
- If your tag set has a different name substitute reference to Tagset in code with your set's name
To set up export, first add two HTML export templates. In both cases there is a line return at the end of the last line of code, i.e. you can place the cursor at the beginning of the line after the last line of code (Code mark-up in the forum can make this aspect ambiguous). In the output text file you want each item's data on a separate line and no blank lines.
1. DT-tags-Wrapper:
Code:Name Tags Text
^children(DT-tags-item)^
N.B. in the first line there is a Tab character between each word.
2. DT-tags-item:
Code:^value($Name)^ ^value($TagSet)^ ^value($Text)^
N.B. there is a Tab character between each ^value()^.
Create an agent. Open it's HTML view and select "DT-tags-wrapper" as the template. Change the export extension from ".html" to ".txt". close HTML view. Via Rename add this query to find all notes with $TagSet data:
$TagSet (yes, it's that simple a query!)
You can of course add extra terms to the query to limit the scope of search, date range, whatever.
Now select the agent, open HTML view and hit the Export button (top right). Nominate an export location (you only get asked for this once per TBX), and export ready for use in DT.
If, as in Alex's original example, you're not exporting $Text then simply amend both templates to remove the last Tab+item, i.e. delete the last column from the export.