Skip to content

Instantly share code, notes, and snippets.

@corpix
Last active April 19, 2018 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corpix/45ecb405eed6dd7a892bac584a33c01f to your computer and use it in GitHub Desktop.
Save corpix/45ecb405eed6dd7a892bac584a33c01f to your computer and use it in GitHub Desktop.
#! /usr/bin/env racket
#lang racket
(require racket/cmdline)
(require csv-reading) ;; $ raco pkg install csv-reading
(define (will-loop executor)
(lambda ()
(let loop ()
(will-execute executor)
(loop))))
(define will-executor (make-will-executor))
(define (will executor value destructor)
(will-register executor value destructor)
value)
;;
(define (print-list-items lst)
(for-each
(lambda (item)
(display (string-trim item))
(newline))
lst))
(define (convert row)
(print-list-items
(string-split (car row) "|")))
(define make-csv-reader
(make-csv-reader-maker
'((separator-chars #\;)
(strip-leading-whitespace? . #t)
(strip-trailing-whitespace? . #t))))
(define (main)
(void (thread (will-loop will-executor)))
(let*
([filename (command-line #:args (filename) filename)]
[filename-port (will
will-executor
(open-input-file filename)
(lambda (port) (close-input-port port)))]
[reader (make-csv-reader filename-port)])
(void (reader)) ;; Skip CSV header
(csv-for-each convert reader))
(void))
(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment