Closed behrica closed 2 years ago
Thanks! Maybe it's not clear in tutorial but regex can be used only to catch groups, ie. this should work: #"(\d)\s{1}(\d)\s{1}(\d)"
. If you want to use regex as a split separator, you can use function #(str/split % #"\s{1}")
.
I'll check the other case later.
Ok, got the second case. It's in doc:
target columns - can be nil or :infer if separator returns map
That means, that you have to somehow provide a names of the columns. Via explicit argument or from a map.
The solution here is to introduce default names.
yes, indeed. I discovered as well that it can be a function. Maybe docu could be improved.
Ok, got the second case. It's in doc:
target columns - can be nil or :infer if separator returns map
What is my version 3) supposed to do ? So the 3-arity function ? I did not find it in docu neither.
And indeed, default column names (column-0 ....) would be useful.
Third version should be something like that: #(zipmap [:x :y :z] (str/split % #"\s{1}"))
I've just found out that second case can be done with "\\s{1}"
(I call re-pattern
under the hood)
I mean, what is the purpose of the 3-arity : separate-columns [ds column separator]
?
Do you have any example of it ?
(tc/separate-column DS :V3 (fn [^double v]
{:int-part (int (quot v 1.0))
:fract-part (mod v 1.0)}))
Sometimes you may want to dynamically decide which column to fill.
While this works:
the next 2 variations don't work: