On 16-2-2012 12:03, Martin wrote:
Admittedly I feel a bit lost when looking at the various processing
modules...

My goal is to create template based output. I have created a rough
mail-merge example (with LibreOffice) and attached it as PDF for
illustration.

There is a CSV database with currently 8 fields, probably a few more
will be added. These fields need to be placed into a form, in my example
a list of courses. Other forms based on the same data should follow.
These forms/lists will then be printed.

Hope that makes sense. Maybe I'm pushing the database module a bit to
far, but I was just trying to avoid "mail-merges"...

\starttext

\startluacode

-- or: str = io.loaddata(somefile)

local str = [[
1,2,3,4,5,6,7,8
a,b,c,d,e,f,g,h
]]

local list = string.splitlines(str)

for i=1,#list do
    local fields = utilities.parsers.settings_to_array(list[i])
    if fields[1] then
        context("field 1: %s",fields[1])
        context.par()
    end
end

\stopluacode

\stoptext

so:

- read in the cvs file
- split them into lines
- loop over each line
- split that line
- and mess around with the fields



-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to