Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit 1c349260391c7f10550965a7bd81c4562840c421 @stathissideris committed Sep 13, 2011
Showing with 61 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. 0 README.md
  3. +5 −0 project.clj
  4. +43 −0 src/moneyz/core.clj
  5. +6 −0 test/moneyz/test/core.clj
@@ -0,0 +1,7 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-failures
+.lein-deps-sum
+/data/
No changes.
@@ -0,0 +1,5 @@
+(defproject moneyz "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dependencies [[org.clojure/clojure "1.2.1"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [incanter "1.2.3"]])
@@ -0,0 +1,43 @@
+(ns moneyz.core
+ (:use (incanter core charts io))
+ (:import (java.text SimpleDateFormat)))
+
+#_(defn read-data
+ "Use incanter's read-dataset instead."
+ [filename]
+ (let [reader (CSVReader. (get-input-reader filename) \, \" 0)
+ data (doall (map seq (seq (.readAll reader))))
+ columns (first data)
+ rows (rest data)]
+ (incanter.core.Dataset. (into [] columns) rows)))
+
+(defn parse-date [date] (.parse (SimpleDateFormat. "dd/MM/yyyy") date))
+(defn parse-dates [dates] (map parse-date dates))
+(defn to-millis [dates] (map #(.getTime %) dates))
+(def process-dates (comp to-millis parse-dates))
+
+(def d1
+ (read-dataset
+ "/Users/sideris/devel/moneyz/data/2011-08-31-statement export.csv"
+ :header true))
+
+(def d2
+ (read-dataset
+ "/Users/sideris/devel/moneyz/data/2011-09-05-statement export.csv"
+ :header true))
+
+(defn merge-statements
+ [d1 d2]
+ (dataset
+ (:column-names d1)
+ (sort-by :Date (distinct (concat (:rows d1) (:rows d2))))))
+
+(defn group-by-account [statement]
+ (into {}
+ (map
+ (fn [[key d]] [key (dataset (:column-names statement) d)])
+ (group-by :Account (:rows statement)))))
+
+(def d (group-by-account (merge-statements d1 d2)))
+
+;;(view (time-series-plot (process-dates ($ :Date d)) ($ :Amount d)))
@@ -0,0 +1,6 @@
+(ns moneyz.test.core
+ (:use [moneyz.core])
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit 1c34926

Please sign in to comment.