Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env racket
- #lang racket
- (define files
- (filter
- (lambda (e) (regexp-match? #rx"[^-ms]\\.csv" e))
- (directory-list (current-directory))))
- ;; (stdin stdout) now point to (in out)
- (define (with-in-out-files proc in out)
- (with-input-from-file in
- (lambda ()
- (with-output-to-file out proc #:mode 'text #:exists 'replace))))
- (define (replace-dot-in-file in)
- (define (dot->comma)
- (for ([l (in-lines)])
- (printf "~a\n" (regexp-replace #rx"\\." l ","))))
- (define (out-filename file suffix)
- (define file-ext (regexp-split #rx"\\." file))
- (string-append (first file-ext) suffix "." (second file-ext)))
- (with-in-out-files dot->comma in (out-filename in "-ms")))
- (time (for-each replace-dot-in-file files))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement