我的问题是如何过滤掉zipmap中似乎是空白键的内容?
虽然我的问题有一个解决方法,但知道如何过滤密钥会非常有帮助.
这个输出
: [: [ ]] ([ ]) 3 ,,
Run Code Online (Sandbox Code Playgroud)
是由
(println first-ent, " ", map-ent, " ", val-ent, " ", (count out-csv), " ", out-csv)
Run Code Online (Sandbox Code Playgroud)
在这个功能
(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)))))
Run Code Online (Sandbox Code Playgroud)
使用空白键的输出具有3的计数允许我进行过滤这一事实看起来不像是能够检测空白键的解决方案.找到并过滤掉一个空白键是我难以接受的.
谢谢.
小智 5
您可以使用以下方法创建空白关键字
(keyword "")
Run Code Online (Sandbox Code Playgroud)
您可以使用它来过滤列表并删除所有空白关键字:
(filter (fn [[key _]] (not= (keyword "") key)) map-ent)
Run Code Online (Sandbox Code Playgroud)