4 ms·
Extracting two columns out of a excel sheet: (->> (d/load-workbook file "Questionnaire.xlsx") (d/select-sheet "Sheet1") (d/select-columns {:
by beders 7y ago
Extracting two columns out of a excel sheet:
(->> (d/load-workbook file "Questionnaire.xlsx")
(d/select-sheet "Sheet1")
(d/select-columns {:A :item :B :price}))
- kgwxd 7y agoWhat is 'd'?
- lastofus 7y agoIt's an alias given to an imported module name. In Python it might be: import really_long_name as rln rln.foo()
- kgwxd 7y agoI know that part :) What module is it referencing?
- sushimako 7y agodocjure https://github.com/mjul/docjure https://github.com/mjul/docjure
- etatidem 7y agoI like the suggestion in namespace aliasing in https://stuartsierra.com/2015/05/10/clojure-namespace-aliases https://stuartsierra.com/2015/05/10/clojure-namespace-aliase...: As a general first rule, make the alias the same as the namespace name with the leading parts removed. (ns com.example.application (:require [clojure.java.io :as io] [clojure.string :as string])) Keep enough trailing parts to make each alias unique. Did you know that namespace aliases can have dots in them? [clojure.data.xml :as data.xml] [clojure.xml :as xml] Eliminate redundant words such as “core” and “clj” in aliases. [clj-http :as http] [clj-time.core :as time] [clj-time.format :as time.format] Then you can see immediately what `d` is... Namely: (require '[dk.ative.docjure.spreadsheet :as spreadsheet]) (You would still not know the library and might have to ask the same question, but it makes more sense.) About `d`: There are always exceptions. For example, some namespaces have established conventions for aliases: [datomic.api :as d]
- jmnicolas 7y agoNow we're talking. It would probably take 20+ lines of C# to do the same thing. How do you manage errors? What happens if Questionnaire.xlsx or Sheet1 doesn't exist ?
- purple_ducks 7y ago> How do you manage errors? It becomes unwieldy like every other language. > What happens if Questionnaire.xlsx or Sheet1 doesn't exist ? Runtime exception. I've seen too much Clojure code (and this goes for every language where error handling is optional - Hi Javascript!) just skip error handling and focus on "happy path". And as demonised as Java's checked exceptions are, they at least forced error handling to be thought of.
- beders 7y agoOr you could use: https://github.com/adambard/failjure https://github.com/adambard/failjure Ya'll underestimate the power of a programming language to create a programming language. Just replace the arrow with `ok->>`