From: Matt Price <moptop99@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: how the $@%& do you add a property to a plist?
Date: Sat, 18 Jul 2015 14:36:19 -0400 [thread overview]
Message-ID: <CAN_Dec890zUJA7QBCd_LGMJv3DU0hN_aS_1qBKfxdMbUcjdf+A@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]
Hi,
I am continuing to work on my marking stuff; it's working really well,
actually.
I am currently importing a list of student names and emails from a csv file
-- this is normally how I get the list of enrolled students. I have
modified the defauly settings from our Universities CSV export so I get
these files in the form:
Student Name,Email
Student One, em.address@utoronto.ca
Student Two, em.address2@utoronto.ca
I then parse this into a list, each element of which is itself a list
("Student One" "em.address@utoronto.ca"), etc.
This is OK, but not very robust. I would like instead to set *properties*,
in case the CSV file has some other ordering of fields. So I've tried this:
(defun parse-plist-csv-file (file)
(interactive
(list (read-file-name "CSV file: ")))
(let ((buf (find-file-noselect file))
(result nil))
(with-current-buffer buf
(goto-char (point-min))
(let ((header (split-string (buffer-substring-no-properties
(line-beginning-position)
(line-end-position)) ","))
)
(while (not (eobp))
(let ((line (split-string (buffer-substring-no-properties
(line-beginning-position)
(line-end-position))))
(count 0)
(new-plist '()))
(while (< count (length line))
(setq plist-new (plist-put new-plist '(nth count header)
(nth count line)))
(setq count (1+ count)))
(push new-plist result)
(forward-line 1))))
(reverse result))))
The line that's not working here is:
(setq plist-new (plist-put new-plist '(nth count header)
(nth count line)))
which just inserts nil nil into 'new-plist. Obviously I'm making some
elementary elsip mistake, but my elisp is too weak to figure it out. Can
you guys help? thanks,
Matt
[-- Attachment #2: Type: text/html, Size: 2603 bytes --]
next reply other threads:[~2015-07-18 18:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-18 18:36 Matt Price [this message]
2015-07-18 20:01 ` how the $@%& do you add a property to a plist? Thomas S. Dye
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN_Dec890zUJA7QBCd_LGMJv3DU0hN_aS_1qBKfxdMbUcjdf+A@mail.gmail.com \
--to=moptop99@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).