[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] cvs2tex

From: Andreas Roehler
Subject: Re: [AUCTeX] cvs2tex
Date: Sun, 03 Dec 2006 12:14:58 +0100
User-agent: Thunderbird (X11/20060516)

David Kastrup schrieb:
Andreas Roehler <address@hidden> writes:

David Kastrup schrieb:
Andreas Roehler <address@hidden> writes:

does someone know a script, reading address from a
cvs-database into tex (letter)?
You mean csv, don't you?
Exactly, sorry.
There is a serial letter macro in Latex; what I need
is to read in separate addresses occasionally,
specified by a regexp.
Your description is less than clear.
Here an example:

From addresses in a file as


an address in tex shall be generated

\address{JOE ANYONE\\
10407 Berlin\\}
It does not sound like describing accurately what you want to have
done, since more than one address will be in the file and it is not
likely that you want to get all \address lines after each other.
Hmm, I wrote:

"to read in separate addresses occasionally,
specified by a regexp."

What about something like

extract an address from a csv-database into a tex letter form?
Could you write a minimal complete example document that would be
supposed to work as you want?
Then it would be done.

_Supposed_ to work.  This may include \usepackage{magic} or similar

I still have no idea what tools are supposed to extract the
addresses and where they should be placed in what manner.

It may be a TeX programming problem that you have in mind, but then
it would make little sense asking on the AUCTeX list.  So I still
have no clue what tool you actually want to do what job on what

Need two things:

- a convenient way to extract data with Emacs from  a csv-database
- write them into the \address{} form

Again: please state the form of your input files, what tools you want
to have working on them, and what results are there.

_What_ is supposed to "extract data"?  Emacs?  What is supposed to
happen if the data changes?  Is this to be a one-time only operation?

;; If exists an ~/my-database.csv with
;; some irrelevant data,JOE,ANYONE,Nickname,Countrcode,Suncity,12345,ANYSTREET,0,some irrelevant data,some more irrelevant data,party leader's birthday ;; some irrelevant data,JOE,SOMEONE,Nickname,Countrcode,Cloudcity,67890,ANYSTREET,0,some irrelevant data,some more irrelevant data,party leader's birthday
;; M-x csv2emacs-lisp
;; should insert:
;; \begin{letter}JOE ANYONE\\
;; ANYSTREET 0\\[\medskipamount]\\
;; {\bf Countrcode Suncity}}
;; in buffer "csv2tex"

;; Code

(defun csv2emacs-lisp (item &rest args)
 "Extract data from a comma-separated-database
Warn if more than one matching record, prompt user then"
 (interactive "sPlease give an regexp to search for: ")
 (find-file "~/my-database.csv")
 (goto-char (point-min))
 (let (line-string
   (counter 0) allmatch)
   (re-search-forward item nil t 1)
(setq line-string (concat line-string (buffer-substring-no-properties (line-beginning-position) (line-end-position))"\n"))
     (setq counter (1+ counter)))
   (if (< 1 counter)
     (if (y-or-n-p "More then one records matched - see all?")
         (message "%s" line-string)
       (message "%s" "Process first matching record")
       (csv2emacs-lisp-intern line-string)))
     (csv2emacs-lisp-intern line-string)

(defun csv2emacs-lisp-intern (linestring)
(let ((line-list (split-string (substring line-string 0 (string-match "\n" line-string)) ",")))
   (with-output-to-temp-buffer "csv2tex" (set-buffer standard-output)
                   (switch-to-buffer (current-buffer))
(insert (concat "\\begin{letter}" (car (nthcdr 1 line-list))" "(car (nthcdr 2 line-list))"\\\\\n" (car (nthcdr 7 line-list))" "(car (nthcdr 8 line-list))"\\\\[\\medskipamount]\\\\\n{\\bf "(car (nthcdr 4 line-list))" "(car (nthcdr 5 line-list))"}}\n"))))
 ;;       (split-window-vertically)
 ;;   (switch-to-buffer "csv2emacs-lisp.el")(end-of-defun)

;; End

reply via email to

[Prev in Thread] Current Thread [Next in Thread]