Message Boards Message Boards

0
|
3255 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Simplify code for data template using FileTemplateApply?

Posted 3 years ago

I have a Dataset of records that contain people's bio details (headshot, job title, and description). I have an XMLTemplate that inserts those data.

t /@ people 

produces a new Dataset that I can then export

Export["biogen.html", (template /@ people) // Normal]

This works fine, but I would prefer to simplify the process by using FileTemplateApply to both apply the template and write the output. The problem is that I can't work out how to evaluate FileTemplateApply on more than one record, i.e. it will work on a single association, but if I try to Map it across multiple associations, I end up with multiple files.

What am I doing wrong?

Cheers, Andy

POSTED BY: Andrew Burnett
2 Replies
Posted 3 years ago

Thanks Rohit, that's good to know.

Cheers Andy

POSTED BY: Andrew Burnett
Posted 3 years ago

Hi Andrew,

FileTemplateApply creates a new file every time it is evaluated, if the file already exists, it is deleted and a new file is created. The code above looks very straightforward and easy to understand. It decouples the generation of the data from the processing (export) which is good and more flexible. I can't think of a way to "simplify" it.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract