Created
July 9, 2013 09:30
-
-
Save gerritjvv/5955996 to your computer and use it in GitHub Desktop.
Count Frequencies of a column in a tsv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def column-n (fn [n sep] (fn [record] (let [s (str record) arr (clojure.string/split s sep)] (arr n))))) | |
(defn file-freq [file column sep] | |
(with-open [ rdr (clojure.java.io/reader file) ] | |
(-> (column-n column sep) (map (line-seq rdr)) frequencies) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interestingly.. i just learnt how to do the same thing using one line cmd in linux today.
cut -d'|' -f | sort | uniq -c