             [grafter.tabular.common :as tabc]
             [grafter.tabular.csv]
             [grafter.tabular.excel]
+            [clojure.tools.logging :refer [spy]]
             [incanter.core :as inc]
             [potemkin.namespaces :refer [import-vars]]))
 

    new-col-ids))

(defn add-columns
  ([dataset hash]
     (let [merge-cols (fn [ds k]
                        (inc/add-column k (repeat (hash k)) ds))
           keys (-> hash keys sort)]
       (reduce merge-cols dataset keys)))

  ([dataset source-cols f]

the specified column being cloned."

  ([dataset new-column-name from-cols]
     (derive-column dataset new-column-name from-cols identity))
  ;; todo support multiple columns/arguments to f.
  ([dataset new-column-name from-cols f]
     (let [resolved-from-cols (resolve-all-col-ids dataset from-cols)]
       (make-dataset (->> dataset
                          :rows
                          (map (fn [row]
                                 (let [args-from-cols (select-row-values resolved-from-cols row)
                                       new-col-val (apply f args-from-cols)]
                                   (merge row {new-column-name new-col-val })))))
                     (concat (column-names dataset) [new-column-name])))))

(defn add-column
  "Add a new column to a dataset with the supplied value lazily copied
  into every row within it."

  [dataset new-column value]

  (derive-column dataset new-column nil (constantly value)))

(defn- infer-new-columns-from-first-row [dataset source-cols f]
  (let [source-cols (resolve-all-col-ids dataset source-cols)
