Skip to content

Commit

Permalink
Fix issues with importing csv and shapefiles (#1744)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-luz authored Jun 17, 2024
1 parent 8faf3ab commit fc25554
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/clj/collect_earth_online/generators/external_file.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@
(str/split r #"\t")
(zipmap header-keys r)
(update r geom-key tc/str->pg "geometry")
(update r :visible_id tc/val->int)))
(update r :visible_id tc/val->float)
(update r :visible_id int)))
(str/split body-text #"\r\n|\n|\r"))]
(if (apply distinct? header-keys)
[header-keys body]
(pu/init-throw (str "The provided "
design-type
" SHP file must not contain duplicate column titles.")))))
design-type
" SHP file must not contain duplicate column titles.")))))

(defmethod get-file-data :csv [_ design-type ext-file folder-name]
(let [rows (str/split (slurp (str folder-name ext-file)) #"\r\n|\n|\r")
Expand Down Expand Up @@ -125,7 +126,8 @@
(split-row r)
(into (ordered-map) (map vector header-keys r))
(assoc r geom-key (tc/str->pg (make-wkt-point (:lon r) (:lat r)) "geometry"))
(update r :visible_id tc/val->int)
(update r :visible_id tc/val->float)
(update r :visible_id int)
(dissoc r :lon :lat)))
(rest rows))]
(if (and (some #(= % :lon) header-keys)
Expand Down

0 comments on commit fc25554

Please sign in to comment.