I'll make a couple of recommendations here:

   1. Try out @davidsantiago's clojure-csv: 
   https://github.com/davidsantiago/clojure-csv. I think it has more 
   formatting/parsing flexibility, and you may find that it "just works (TM)".
   2. For getting from maps to a sequence of vectors suitable for 
   clojure-csv or data.csv, you might want to look at my semantic-csv 
   library: http://metasoarous.github.io/semantic-csv/. Translating between 
   maps and vectors, and casting values based on column were some of the core 
   motivations behind it's construction, so you might find it helpful. Note 
   that it's really just a collection of processing utilities, and doesn't 
   offer any parsing of it's own (other than two convenience functions 
   wrapping data.csv). It's designed to be compatible with clojure-csv, 
   data.csv, or any custom formatting/parsing solution you might need.

Hope this is helpful.

Chris


On Monday, March 23, 2015 at 3:44:13 PM UTC-7, blake wrote:
>
> I just did this but for a more complex data structure so it doesn't quite 
> map to your example. I did it this way:
>
>
> 1. Stringify-keys
> 2. Merge the data, then pull the keys to get the unique fields
> 3. Join all the keys got in part 2 with "," to create a header record
> 4. Now, for each record, pull the value for each of the keys you discovered
> 5. Surround with quotes, if you might have commas in the data, or use tab 
> separators to avoid that mess
> 6. Join each field in the record with a comma.
> 7. Join all the records with a newline.
>
> I also filtered out restricted records and my map was not flat, so I 
> flattened it. I'm also pulled the data out of a database based on a 
> filtered search, so the whole thing took about 16 lines. Without all that 
> nonsense, it'd probably be 7-8 lines.
>

-- 
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 from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to