dirtyvagabond / c4

0 stars 0 forks source link

automatic String-ification of attr values #4

Open dirtyvagabond opened 11 years ago

dirtyvagabond commented 11 years ago

The csv library explodes on non-String values, e.g. if the value is a vector:

java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String

So c4 step authors are forced to handle String-ification on their own, e.g.:

RCfinal.tab <- flat-report.json [c4rows]
 (let [attrs (str/split (slurp "resource/internal_attrs.txt") #"\n")]
   (apply columns! attrs)
   (map
     (fn [row]
       (into {}
         (map #(vector (key %) (str (val %))) row)))
     rows))

Need to decide what, if any, format to use for structures like vectors. I've seen people trying to convert nested json to tsv then back to json. If that's even sane, would be nice to support.

dirtyvagabond commented 11 years ago

Also, with things like numeric postcodes starting with 0, the right thing should just automatically happen. That is, 01234 should not end up showing as 1234 in an OpenOffice spreadsheet. Review clojure-csv's latest philosophy on this.