Created
July 13, 2020 02:43
-
-
Save Fusion/271193a6fc237916a6800c6874b8f70b to your computer and use it in GitHub Desktop.
Silly Python to Clojure test
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
(let [[jirafilepath tempofilepath mergedfilepath] *command-line-args*] | |
(when (or (empty? jirafilepath) | |
(empty? tempofilepath) | |
(empty? mergedfilepath)) | |
(println | |
"Please provide path to {jira export file} {temport export file} {merged file}") | |
(System/exit 1)) | |
(with-open [reader (io/reader jirafilepath)] | |
(let [csv-data (csv/read-csv reader)] | |
(let [rows (map zipmap | |
(->> (first csv-data) | |
(map keyword) | |
repeat) | |
(rest csv-data))] | |
; Creates a persistent hash map | |
(println | |
(reduce (fn [acc row] | |
(assoc acc | |
(row :task) | |
(+ (if (nil? (acc (row :task))) 0 (acc (row :task))) | |
(read-string (row :hours))))) | |
{} | |
rows)))))) |
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
import sys | |
import csv | |
if len(sys.argv) != 4: | |
print("Please provide path to {jira export file} {temport export file} {merged file}") | |
sys.exit(1) | |
jirafilepath = sys.argv[1] | |
tempofilepath = sys.argv[2] | |
mergedfilepath = sys.argv[3] | |
effort = {} | |
with open(jirafilepath, newline='') as jirafile: | |
reader = csv.DictReader(jirafile) | |
for row in reader: | |
if row['task'] not in effort: | |
effort[row['task']] = 0 | |
effort[row['task']] += float(row['hours']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment