Created
July 15, 2012 10:24
-
-
Save mowat27/3116194 to your computer and use it in GitHub Desktop.
Text stream to/from record structure sketch
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
(def pipe_delim_text | |
"Lorem|ipsum|dolor | |
sit|amet,|consectetur | |
") | |
(def fixed-width-text "122333455666") | |
(defrecstruct lorem-record | |
(:field1 (delimiter "|")) | |
(:field2 (delimiter "|")) | |
(:field3 (delimiter "|")) | |
(:newline (delimiter "\n")) | |
) | |
(lorem-record pipe_delim_text) | |
; => Lazy Seqeunce [ | |
; {:field1 "Lorem" :field2 "ipsum" :field3 "dolor", :newline "\n"} | |
; {:field1 "sit" :field2 "amet," :field3 "consectetur", :newline "\n"} ] | |
(defrecstruct numbers-record | |
(:x (length 1)) | |
(:y (length 2)) | |
(:z (length 3)) | |
) | |
(numbers-record fixed-width-text) | |
; => Lazy Sequence [ | |
; {:x 1 :y 22 :z 333} | |
; {:x 4 :y 55 :z 666} ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment