From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: how the $@%& do you add a property to a plist? Date: Sat, 18 Jul 2015 14:36:19 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf307ac3a597ef9b051b2a94ff Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGWyC-0006Gs-Pc for emacs-orgmode@gnu.org; Sat, 18 Jul 2015 14:36:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZGWyB-0007kE-NA for emacs-orgmode@gnu.org; Sat, 18 Jul 2015 14:36:20 -0400 Received: from mail-vn0-x233.google.com ([2607:f8b0:400c:c0f::233]:33073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGWyB-0007ju-Hg for emacs-orgmode@gnu.org; Sat, 18 Jul 2015 14:36:19 -0400 Received: by vnav141 with SMTP id v141so11126367vna.0 for ; Sat, 18 Jul 2015 11:36:19 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode --20cf307ac3a597ef9b051b2a94ff Content-Type: text/plain; charset=UTF-8 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 --20cf307ac3a597ef9b051b2a94ff Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+PGRpdj48ZGl2PjxkaXY+PGRpdj48ZGl2PjxkaXY+PGRpdj48ZGl2Pjxk aXY+PGRpdj5IaSw8YnI+PGJyPjwvZGl2PkkgYW0gY29udGludWluZyB0byB3b3JrIG9uIG15IG1h cmtpbmcgc3R1ZmY7IGl0JiMzOTtzIHdvcmtpbmcgcmVhbGx5IHdlbGwsIGFjdHVhbGx5LsKgIDxi cj48YnI+PC9kaXY+SSBhbSBjdXJyZW50bHkgaW1wb3J0aW5nIGEgbGlzdCBvZiBzdHVkZW50IG5h bWVzIGFuZCBlbWFpbHMgZnJvbSBhIGNzdiBmaWxlIC0tIHRoaXMgaXMgbm9ybWFsbHkgaG93IEkg Z2V0IHRoZSBsaXN0IG9mIGVucm9sbGVkIHN0dWRlbnRzLsKgIEkgaGF2ZSBtb2RpZmllZCB0aGUg ZGVmYXVseSBzZXR0aW5ncyBmcm9tIG91ciBVbml2ZXJzaXRpZXMgQ1NWIGV4cG9ydCBzbyBJIGdl dCB0aGVzZSBmaWxlcyBpbiB0aGUgZm9ybTo8YnI+PGJyPjwvZGl2PlN0dWRlbnQgTmFtZSxFbWFp bDxicj48L2Rpdj5TdHVkZW50IE9uZSwgPGEgaHJlZj0ibWFpbHRvOmVtLmFkZHJlc3NAd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