Tinderbox Forum

Export file constructed with Event Prototype

I am creating a file by using the Event Prototype to build a chronology for a detailed historical narrative. How would I export that file so that it could be opened by Excel or Numbers for printing?

There are a few threads here on exporting to CSV or exporting to spreadsheet. If you search, you’ll find them.

Feels like a shameless plug, but if you are completely new to export, maybe these posts will help. There is a CSV example near the end.

1 Like

Further to the above (with which I agree), why export just to print? If that is the only reason for export, please explain what you are trying to visualise in print (PDF?) form? Why is is needed thus? For instance, it might be so data is in dread-tree format than can be pinned on the wall. Anyway, what is the real underlying issue here? It might be you don’t need to print anything, but just to visualise it in a better way within the app.

Thank you Brian.

I am an older person and much prefer to proof/correct from text on paper. Also, as a person who learned my trade in the COBOL/80 col card era, I rather like dead trees on the wall. The big picture and all that. Apart from the prejudices of an obsolete mind, export to CSV would me to move data to timelines other than TBX for format experiments and the like.

In addition to the export examples that you can find here and there in this forum and elsewhere, you might also try the (relatively new) external scripting functionality. Scripts are fiddly to write, but once written, are easy to use and reuse on different documents. They also make it easy to add/delete attributes to export and to change the column order. You don’t need to know AppleScript or JavaScript to use them.

This one should do what you want (it works well for me with Numbers, and Excel):

set attribsToExport to {"Name", "StartDate", "EndDate"}

set text item delimiters to quote & "," & quote # comma-delimited
copy attribsToExport to attribValsListOfLists #list to hold lists of attribute values
set numCols to length of attribsToExport

tell application "Tinderbox 8"
	tell selections of front document
		repeat with i from 1 to numCols
			set attrName to item i of attribsToExport
			tell attribute attrName
				set item i of attribValsListOfLists to its value
				if type of item 1 is "date" then
					set item i of attribValsListOfLists to my convertDates(item i of attribValsListOfLists)
				end if
			end tell
		end repeat
	end tell
end tell

set numRows to length of item 1 of attribValsListOfLists
set outStr to quote & attribsToExport & quote & return # header row

repeat with i from 1 to numRows
	set rowItems to {}
	repeat with j from 1 to numCols
		set end of rowItems to item i of item j of attribValsListOfLists
	end repeat
	set outStr to outStr & quote & rowItems & quote & return # body row
end repeat

set the clipboard to outStr
return outStr -- to view in result panel of Script Editor

to convertDates(listOfIsoDates)
	-- convert list of Tinderbox ISO 8601 dates to date-time string for spreadsheets
	set convertedDates to {}
	repeat with i from 1 to length of listOfIsoDates
		tell item i of listOfIsoDates
			if it is "never" then
				set end of convertedDates to ""
			else
				set end of convertedDates to text 1 thru 10 & " " & text 12 thru 19
			end if
		end tell
	end repeat
	return convertedDates
end convertDates
  1. Copy-paste into Script Editor (in Applications > Utilities)
  2. The first time, make sure Script Editor, Tinderbox, and Numbers are listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility
  3. Edit the first line of the script, if needed, to include more attributes, or to change the order.
  4. In Tinderbox select the event notes you want to export.
  5. Click the triangle ‘run’ button in Script Editor.

This places the data on the clipboard. Then in Numbers (or Excel) click a cell and type command-v to paste. Numbers should place the data automatically in columns. In Excel, which gives you much more control over printing, you may need to use ‘Text to Columns’ and choose comma as the delimiter.

1 Like

Thanks very much for this detailed suggestion. I shall try to experiment.