                           io/input-stream
                           (XZCompressorInputStream. true)
                           io/reader)]
-    (doall
-     (csv/read-csv in-file)))
-)
+    (doall (csv/read-csv in-file)))
+  )
 
 (defn analizza-dati [dati]
   (let [colonne [:2016 :2015 :2014 :siope :desc]

  (:import (org.apache.commons.compress.compressors.xz XZCompressorInputStream))
  )

(defn apri-xz
  "apri un file singolo compresso con xz, restituisce io/reader"
  [filename]
  (with-open [in-file (-> filename

    df
  ))

(defn cerca-enti

  ;; 1 cod_ente siope
  ;; 2 data_inc_siope date,
  ;; 3 data_esc_siope date,
  ;; 4 cod_fiscale character(16),
  ;; 5 descr_ente character varying,
  ;; 6 cod_comune character(3),
  ;; 7 cod_provincia character(3),
  ;; 8 num_abitanti character varying,
  ;; 9 sottocomparto_siope character varying,

  ([needle]
   (->> (apri-csv-xz "assets/ANAG_ENTI_SIOPE.D160624.H0102.csv.xz")
        ;; fast grep on all lines as strings to exclude bulk non matching
        (keep #(if (string/includes? (str %) (string/upper-case needle)) %))
        (into [["codice" "creazione" "scadenza" "fiscale" "nome" "comune" "provincia" "popolazione" "comparto"]])
        mappify ;; this takes time
        ))

  ([needle pos]
   (->> (cerca-enti needle)
        (keep #(if (= (pos %) needle) %))
        ))

)

(defn raccogli-tutto
  "Raccoglie tutti i dati disponibili su qualsiasi ente la cui descrizione contiene la stringa"
