Fork me on GitHub
#babashka
<
2021-10-25
>
dabrazhe13:10:44

What can bb do with excel? I have an office 365 sheet to which I want to append some extra CSV file i will render myself. Ideally without saving the office cloud sheet locally

borkdude13:10:19

There isn't a babashka excel library or pod as far as I know of, but for this use case you could try #nbb, which is a similar tool like babashka, but for Node.js: https://github.com/babashka/nbb/blob/main/examples/exceljs/example.cljs

borkdude13:10:49

or shell out to a CLI, for example csvkit offers support for this

dabrazhe14:10:02

Thank you, will have a look

gigal00p13:10:23

Hi babashka users! What is the preferred way to parse date time strings in the tool? I've just got an error:

----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Could not find namespace: clojure.instant.
Location: /Users/walkiewk/code/clojure/bb/./gcp_assets.clj:6:3

borkdude13:10:33

more specifically java.time.format.DateTimeFormatter

borkdude13:10:48

+ LocalDateTime.parse

gigal00p13:10:39

Thanks @U04V15CAJ - I somehow missed in the docs that java.time is included 😄

👍 1
borkdude13:10:14

Thanks for the feedback, we should make that more apparent

gigal00p13:10:57

Eee, I've just double checked - java.time is not mentioned in the docs.

borkdude13:10:32

"Selection of Java classes" is mentioned

borkdude13:10:38

but this needs improving ;)

gigal00p13:10:43

I hoped to use instant/read-instant-date

Benjamin17:10:04

how does io/resource work differently with bb? I have a bb server running and there are files in /resources/foo.edn but io/resource doesn't find them

borkdude17:10:25

@benjamin.schwerdtner you have to add resources to the classpath

Benjamin17:10:51

ah :paths in deps.edn?

borkdude17:10:52

e.g in bb.edn : :paths ["resources"]

borkdude17:10:17

or bb --classpath resources ...

Benjamin17:10:07

Thanks! --classpath worked and bb.edn not. Now I released that my bb-server script overrode the classpath. I think I took that from some the book or somewhere

#!/usr/bin/env bb

(import [ ServerSocket]
        [ File]
        [java.lang ProcessBuilder$Redirect])

(require '[babashka.wait :as wait])

(let [nrepl-port (with-open [sock (ServerSocket. 0)] (.getLocalPort sock))
      cp (str/join File/pathSeparatorChar ["src" "test"])
      pb (doto (ProcessBuilder. (into ["bb" "--nrepl-server" (str nrepl-port)
                                       "--classpath" cp]
                                      *command-line-args*))
           (.redirectOutput ProcessBuilder$Redirect/INHERIT))
      proc (.start pb)]
  (wait/wait-for-port "localhost" nrepl-port)
  (spit ".nrepl-port" nrepl-port)
  (.deleteOnExit (File. ".nrepl-port"))
  (.waitFor proc))
I will change my version so it uses the bb.edn path, if there

borkdude17:10:54

yes, this was in the book before but I changed this example since there are better options now

borkdude18:10:12

The book now has this:

{:tasks
 {:requires ([babashka.fs :as fs]
             [babashka.process :as p :refer [process]]
             [babashka.wait :as wait])
  nrepl (let [port (with-open [sock (java.net.ServerSocket. 0)] (.getLocalPort sock))
              proc (process (str "bb nrepl-server " port) {:inherit true})]
          (wait/wait-for-port "localhost" port)
          (spit ".nrepl-port" port)
          (fs/delete-on-exit ".nrepl-port")
          (deref proc))}}

catjam 1