Skip to content

Instantly share code, notes, and snippets.

@bobbicodes
Created February 24, 2022 23:39
Show Gist options
  • Save bobbicodes/803542dd22493eae27c8f8d84c641e9a to your computer and use it in GitHub Desktop.
Save bobbicodes/803542dd22493eae27c8f8d84c641e9a to your computer and use it in GitHub Desktop.
Tofino data processing
(ns tofino
(:require [clojure.string :as str]))
(defn rows [page]
(map #(str/split % #"\s+")
(str/split-lines (slurp page))))
(defn barcode [row]
(first row))
(defn barcode3
"Returns nil if item has only one barcode."
[row]
(when-not #(= % "$0.00")
(second row)))
(defn item
"The item # is always the one after the price,
and we are only dealing with $0.00 items."
[row]
(second (drop-while #(not= "$0.00" %) row)))
(defn dssi? [row]
(contains? (set row) "DSSI"))
(comment
(map item
(remove dssi? (drop 340 (rows "4"))))
(barcode (nth (rows "4") 382))
(dssi? (nth (rows "4") 382))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment