Fork me on GitHub
#clojure-nl
<
2019-09-18
>
thomas08:09:09

Buono Estente

thomas08:09:17

the bot has a day off.

Mno08:09:59

Iterluarit (Greenlandic)

Mno08:09:34

Have a nice holiday Mr.Borkbot :robot_face:

skuro13:09:33

finally had the chance to put the good babashka to use!

skuro13:09:45

I'm usually well versed with bash, but not so much with awk / perl wizardry. I had a misformed CSV file which didn't quote columns when the value itself contained the separator. the number of columns of each entry was known, so I had to surround the first TOTAL_COLUMNS - EXPECTED_COLUMNS when TOTAL_COLUMNS > EXPECTED_COLUMNS

skuro13:09:28

spent about 10m looking for pure-bash solutions

skuro13:09:41

then concocted a bb script and lived happily ever after 🙂

👍 8
skuro13:09:56

(I'd still be curious if you guys could come up with a native non-clj approach :P)

borkdude14:09:30

Great to hear 🙂

Mno15:09:32

Cool, can I see the script? It seems like it'd be a nice reference.

skuro15:09:25

this last version has the extra addition of changing the separator to semicolon to make the Excel of my colleagues happier

skuro15:09:26

(for [line *in*]
  (let [pieces (str/split line #"," -1)]
    (if (>= 11 (count pieces))
      (str/replace line "," ";")
      (let [[first-pieces other-pieces] (split-at (- (count pieces) 10) pieces)
            first                       (str \" (str/join "," first-pieces) \")]
        (str/join ";" (into [first] other-pieces))))))

skuro15:09:33

aptly named fix-s***.bb

Mno15:09:34

I love it.