Welcome to the CHICKEN Scheme pasting service

csv magic pasted by ente on Fri Sep 28 14:38:13 2012

(use csv csv-string)

(define parse (csv-parser #\;))

(define (parse-from-port #!optional (port (current-input-port)) (prev '()))
  (let* ((line (read-line port))
         (recs (if (and line (not (eq? line #!eof)))
                  (map csv-record->list (parse line))
                  #f)))
  (if recs 
    (parse-from-port port (append prev (list recs))) 
    prev)))

(print (parse-from-port))

annotated version pasted by ente on Fri Sep 28 15:16:23 2012

;reading line by line is stupid because it breaks newline escaping etc.
;Luckily, DerGuteMoritz came up with the following:
(port-map (o csv-record->list car parse) (lambda () (read-line port)))

getting things wrong the n+1th time pasted by ente on Fri Sep 28 15:19:59 2012

; Apparently, I misunderstood him: "ok anyway, your newline-escaping-unaware code can be reduced to one line!"
; so the right way to do it is reading the entire port until eof and then using that as input for
; parse and then csv-record->list.

csv, the last added by ente on Fri Sep 28 17:54:51 2012

(use utils csv csv-string)

(define parse (csv-parser #\;))

(define (read-file)
	(map csv-record->list (parse (read-all))))

(pp (read-file))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg provides `hash-table-ref'?
Visually impaired? Let me spell it for you (wav file) download WAV