Need some help here in exporting a number of SELECTED notes to a single csv file?
I can easily export single notes, one at at time using the a template with the code:
^value($Name),^value($Text)[return]
This produces a single txt file that I manually do one at a time:
Title of note1,Text of note1
What I want is to select multiple notes and exported all of them to a single csv text file, ex:
Title of note1, Text of note1
Title of note2, text of note2
Title of note3, text of note3
Is there a way to set up an export template to handle multiple selected notes and export a csv .txt file?
In short, no. The simplest method is to use an agent. The agent exports nothing but also exports all its children like so. Letās assume your template above is called ācsv-itemā. The agentās export template, ācsv-listā, is:
^children("csv-item")^
Agents (by default) donāt export child notes so exporting the agent will create sone file with your CSV data in it.
If you donāt want to use an agent, perhaps because thee selection doesnāt make an easy query, you can simulate the process with a container. Make a new container and give it the export template ācsv-listā. Also, on the export inspector un-tick āexport childrenā. Now make aliases of your selected notes and drag those into your new export container. Export and then delete the aliases; you might want to keep the container for the next ad-hoc export of this type.
Thanks Mark, worked like a charm and does exactly what I want!
Just to clarify, we have 2 new templates:
csv-envelope with the code: ā^children(ācsv-itemā)^ā
csv-item with the code: ā^value($Name),^value($Text)[return]ā NB: [return] is really the return character and not the code
Use the container: either manually placing the aliasās of the notes you want or via an agent.
Set the export template of the container to the ācsv-envelopeā
set the export templates of the aliasās to the " csv-item"
UNCHECK the export children selection box in the export inspector.
Works as advertised: Question: How could you modify the script if you wanted to print each out as separate individual text files? What script could you apply to the wrapper?
Tip, use the forum mark-up for code, otherwise your straight quotes get auto-converted to curly ones and anyone using the result in code will get an error.
I think no, because the whole point of the export selected note feature is to support exporting a single object. Even if that note would otherwise export its children, it doesnāt when using this feature.
Actually, if you set the envelopeās $ExportChildren to true, then Tinderbox will
Export the envelope, which then includes a line for each child
Make a folder for the children
Export each child, using that childās own export template.
For example, in my weblog each month is a container. The container exports each post in the month in one long page named (say) May2018.html, and each post is exported to a separate page, too.
EDIT: I was being sloppy. This is true when exporting the whole document, but not when exporting only the selected note.