   (html/html-resource (java.io.FileReader. filename)))
 
 (defn get-exercises [imported-html]
+  "First one is a heading, so choose rest of TR-elements."
   (rest (html/select imported-html [:tr])))
 
 (defn is-ex? [ex-html]

                   :tags (get-tags exercise)
                   }))

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

    (.getTime (java.util.Date. (- (nth date-array 2) 1900) 
                               (+ 1 (second date-array)) 
                               (first date-array) 12 0))))
(defn get-or-create-login-id [login-id]
    (let [_login-id (mc/find-one "onuser" {:_id login-id})]
      (if (= nil _login-id) (mc/insert "onuser" {:_id login-id}))
      login-id))

(defn get-timestamp [exercise]
  (convert-to-timestamp (html/text (nth exercise 0))))

(defn get-heading [exercise] (html/text (nth exercise 1)))

(defn get-or-create-sport [exercise]
  "XXX: not thread safe!??"
  (let [sport-id (html/text (nth exercise 2))
        _sport-id (mc/find-one "onsport" {:_id sport-id})]
    (if (= nil _sport-id) (mc/insert "onsport" {:_id sport-id}))
    sport-id))

(defn get-report [exercise] 
  "Emits the html in report and joins all strings in it."
