我的问题是如何过滤掉zipmap中似乎是空白键的内容?
虽然我的问题已解决,但知道如何过滤密钥会非常有帮助。
此输出
: [: [ ]] ([ ]) 3 ,,
由
制作(println first-ent, " ", map-ent, " ", val-ent, " ", (count out-csv), " ", out-csv)
在这个函数中
(defn missing-accts
"Prints accounts found in one report but not the other."
[report-header mapped-data out-file]
(spit out-file (str "\n\n" report-header "\n\n") :append true)
(doseq [map-ent mapped-data]
(let [first-ent (first map-ent)
val-ent (rest map-ent)
out-csv (if first-ent
(str (name (key map-ent)) "," (first (val map-ent)) "," (last (val map-ent)) "\n")
nil)]
(println first-ent, " ", map-ent, " ", val-ent, " ", (count out-csv), " ", out-csv)
(if (> (count out-csv) 3)
(spit out-file out-csv :append true)
(println "Skipping: ", out-csv)))))
使用空白键的输出计数为3的事实允许我进行过滤似乎不是一个干净的解决方案,因为能够检测到空白键。找到并过滤掉一个空白键是我难以接受的。
谢谢。
答案 0 :(得分:5)
您可以使用以下方式创建空白关键字:
(keyword "")
您可以使用此功能过滤列表并删除所有空白关键字:
(filter (fn [[key _]] (not= (keyword "") key)) map-ent)