Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 
Send Topic Print
Exporting Tagged Files? (Read 13943 times)
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Exporting Tagged Files?
Reply #15 - Jun 7th, 2011, 2:57am
 
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.

Back to top
 
« Last Edit: Jun 07th, 2011, 8:50am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Exporting Tagged Files?
Reply #16 - Jun 7th, 2011, 8:49am
 
This was my original follow up to Paul's answer (#14  above) before it proved necessary to change from CSV to tab-delim data.

~~~~~~~~ Original CSV based data ~~~~~~~~~~~~
1. DT-tags-Wrapper:
Code:
Name,Tags,Text
^children(DT-tags-item)^
 


2. DT-tags-item:
Code:
"^value($Name)^","^value($TagSet)^","^value($Text)^"
 



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 use:
Code:
Name,Tags
^children(DT-tags-item)^
 


and
Code:
"^value($Name)^","^value($TagSet)^"
 



Notes re use of Comma Separated Variable (CSV) format:
  • If values contain commas, they must be enclosed in straight double quotes.
  • If values contain line breaks (paragraphs) or leading/trailing white space they must be enclosed in straight duoble-quotes.
  • I've quoted all 3 fields above as $Name or $Text might contain commas.
  • Quoted values can contain straight double quotes but such characters must be doubled. So 'I said "Hello" to him' must - for CSV value usage become 'I said ""Hello" to him'. Tinderbox has no built-in method for this. Suggestions: either use curly double quotes inline within your $Text instead of straight noes, or write a command line to double any quotes. The latter would need to be done via runCommand pre or during export. Don't use $HTMLExportCommand as we don't want the quotes enclosing values to also be doubled
  • This page seems a useful reference on the 'rules' of CSV.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1 2 
Send Topic Print