-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
35 lines (28 loc) · 901 Bytes
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns clojask-io.core
(:require [clojure.java.io :as io]
[clojure.string :as str]
;; [pigpen.core :as pig]
;; [pigpen.parquet :as pqt]
))
(def format-sep-map {"csv" ","
"txt" ", "
"dat" " +"
"tsv" "\t"
"tab" "\t"})
(def gen-format ["csv" "txt" "dat" "tsv" "tab"])
(def excel-format ["xls" "xlsx"])
(defn infer-format
"infer the file format from a path, otherwise return nil"
[path]
(let [index (str/last-index-of path ".")
format (if (not= index nil) (subs path (inc (str/last-index-of path "."))) nil)]
format))
(defn is-general
[path]
(.contains gen-format (infer-format path)))
(defn is-excel
[path]
(.contains excel-format (infer-format path)))
(defn supports
[format]
(or (is-general format) (is-excel format) (= format nil)))