faster-but-slower-json pasted by eggless on Wed Feb 25 22:25:48 2015

(define (json->csv in-file out-file)
  (let ((keys (with-input-from-file in-file
		(lambda ()
		  (non-nested-keys (read-json (read-line)))))))
    (with-output-to-file out-file
      (lambda ()
	;; Write the csv header
	(write-csv (list keys))
	(call-with-input-file in-file
	  (lambda (in)
	    (let loop ((in in) (result '()))
	      (receive (object remainder)
		  (read-json in consume-trailing-whitespace: #f chunk-size: (* 5 1024))
		(if object
		    (loop remainder (cons object result))
		    (for-each (lambda (curr-result)
		    		(write-csv (list (alist->nested-list
						  curr-result keys))))
		    	      result))))))))))

like this pasted by DerGuteMoritz on Wed Feb 25 22:37:28 2015

(define (json->csv in-file out-file)
  (let ((keys (with-input-from-file in-file
		(lambda ()
		  (non-nested-keys (read-json (read-line)))))))
    (with-output-to-file out-file
      (lambda ()
	;; Write the csv header
	(write-csv (list keys))
	(call-with-input-file in-file
	  (lambda (in)
	    (let loop ((in in))
	      (receive (object remainder)
                (read-json in consume-trailing-whitespace: #f chunk-size: (* 5 1024))
                (write-csv (list (alist->nested-list object keys)))
		(if object
		    (loop remainder))))))))))

More like this added by DerGuteMoritz on Wed Feb 25 22:38:15 2015

(define (json->csv in-file out-file)
  (let ((keys (with-input-from-file in-file
		(lambda ()
		  (non-nested-keys (read-json (read-line)))))))
    (with-output-to-file out-file
      (lambda ()
	;; Write the csv header
	(write-csv (list keys))
	(call-with-input-file in-file
	  (lambda (in)
	    (let loop ((in in))
	      (receive (object remainder)
                (read-json in consume-trailing-whitespace: #f chunk-size: (* 5 1024))
                (when object
                  (write-csv (list (alist->nested-list object keys)))
                  (loop remainder))))))))))