Skip to content

Instantly share code, notes, and snippets.

@bizenn
Last active December 12, 2015 07:28
Show Gist options
  • Save bizenn/4736712 to your computer and use it in GitHub Desktop.
Save bizenn/4736712 to your computer and use it in GitHub Desktop.
Labeled TSV reader/writer casual implementation.
;;; -*- 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)))))
@bizenn
Copy link
Author

bizenn commented Feb 8, 2013

This implementation works only with current HEAD Gauche.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment