                {:db/id (d/tempid :db.part/glossa)
                 :metadata_value value})
              headers fields))
-      (create-metadata-value-maps val-id-map categories))))
+      (create-metadata-value-maps val-id-maps headers categories))))

              (filter #(seq (val %)) (zipmap attr-names row))))  ;ignore empty strings
      {:from-path path})))

(defn- create-metadata-value-maps [val-id-map categories]
  (for [category-vals val-id-map
        [val id] category-vals]
    {:db/id (d/tempid :db.part/glossa (- -1 id))
     :metadata-value/text-value val}))

(defn import-corpora []
  (tsv->tx-data (str data-path "/corpora.tsv") :corpus))

          unique-vals (map set cols)
          tids (first unique-vals)
          nrows (count tids)
          val-id-maps (map-indexed (fn [index cat-vals]
                                     (let [first-id (* index nrows)]
                                       (into {}
                                             (map (fn [val id] [val id])
                                                  cat-vals
                                                  (map #(+ % first-id) (range nrows))))))
                                   unique-vals)]
      (when-not (= (first headers) "tid")
        (throw (Exception. (str "The first column should be tid, not " (first headers) "!"))))
      (for [row data
