ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: error with m-database example
Date: Thu, 16 Feb 2012 13:16:19 +0100	[thread overview]
Message-ID: <4F3CF393.4020506@wxs.nl> (raw)
In-Reply-To: <4F3CE268.2060401@yahoo.com>

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	other threads:[~2012-02-16 12:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 15:06 Martin
2012-02-15 20:12 ` Wolfgang Schuster
2012-02-15 20:54   ` Martin
2012-02-15 21:08     ` Wolfgang Schuster
2012-02-16 11:03       ` Martin
2012-02-16 12:16         ` Hans Hagen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-12-19 19:37 Florian Wobbe
2010-12-20 16:56 ` Mojca Miklavec
2010-12-20 17:46   ` Florian Wobbe
2010-12-20 21:32   ` Hans Hagen
2010-12-21  8:20     ` Florian Wobbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F3CF393.4020506@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).