Re: Reading data from a file into a struct

2010-02-11 Thread Michał Marczyk
On 11 February 2010 22:48, Base wrote: > Fantastic! > > A million thank yous Michal! Not at all. :-) Sincerely, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts fro

Re: Reading data from a file into a struct

2010-02-11 Thread Base
Fantastic! A million thank yous Michal! On Feb 11, 3:40 pm, Michał Marczyk wrote: > How about > > (for [line (ds/read-lines file)] >   (apply struct location >     (rest (re-match #"([\w ]+)\t([\w ]+)\t([\w ]+)\t" line > > ? > > Or > > (for [line (ds/read-lines file)] >   (let [[_ city state

Re: Reading data from a file into a struct

2010-02-11 Thread Michał Marczyk
How about (for [line (ds/read-lines file)] (apply struct location (rest (re-match #"([\w ]+)\t([\w ]+)\t([\w ]+)\t" line ? Or (for [line (ds/read-lines file)] (let [[_ city state zip] (re-match #"..." line)] ; possibly with regex from above (struct location city state zip))) Us

Reading data from a file into a struct

2010-02-11 Thread Base
Hi All – I would like to read in a text file and map the results to a struct, and seem to be hung up. The data set would look like: Minneapolis\tMN\t55409 Beverly Hills\tCA\t90210 New York City\tNY\t10023 Etc…. Using duck streams: (defn load-data [f] (into [] (ds/read-lines f))) Yields a lo