Last active
December 12, 2015 07:28
-
-
Save bizenn/4736712 to your computer and use it in GitHub Desktop.
Labeled TSV reader/writer casual implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- mode: scheme; coding: utf-8 -*- | |
(define-module text.ltsv | |
(use srfi-13) | |
(use text.csv) | |
(export-all)) | |
(select-module text.ltsv) | |
(define ltsv-reader | |
(let1 tsv-reader (make-csv-reader #\tab) | |
(^ [in] | |
(let1 rec (tsv-reader in) | |
(if (eof-object? rec) | |
rec | |
(map (cut string-split <> #\: 1) rec)))))) | |
(define ltsv-writer | |
(let1 tsv-writer (make-csv-writer #\tab) | |
(^ [rec out] | |
(tsv-writer out (map (cut string-join <> ":") rec))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This implementation works only with current HEAD Gauche.