             (catch Exception e 
                 (prn uid e excercise)))]))
 
-(defn -main []
-    (let [uid (get-uid "peppi")]
+(defn -main [& args]
+	"First arg is an username, and second Lenkkari's export filename."
+    (let [uid (get-uid (first args))
+          imported-html (import-html (second args))]
         (try
-            (doall (map #(if (is-ex? %) (insert uid (get-ex %))) exs))
+            (doall (map #(if (is-ex? %) (insert uid (get-ex %))) (exs imported-html)))
         (catch Exception e (prn e)))))

(require '[clojure.java.jdbc :as sql])
(require '[net.cgrand.enlive-html :as html])

(def import-html (html/html-resource (java.io.FileReader. "peppi-trainlog.html")))

(def exs (rest (html/select import-html [:tr])))

(defn is-ex? [ex-html]
    (= 10 (count (get ex-html :content))))

(defn get-ex [ex-html]
    (get ex-html :content))

(defn convert-to-timestamp [date-string]

             (if (> (count results) 0) (get (first results) :id) 0)))))


(defn get-report [ex] 
	"Emits the html in report and joins all strings in it."
	(reduce #(str %1 %2) (html/emit* (nth ex 3))))

(defn get-distance [ex]
    "Returns meters. Input: 42,195, output 41295"
    (let [distance-string (html/text (nth ex 5))]
        (int (* 1000 (read-string (clojure.string/replace distance-string #"," "."))))))

