Last active
June 10, 2021 08:10
-
-
Save Arkoniak/595594a55b4d439b4827a0c2831eb2d5 to your computer and use it in GitHub Desktop.
Example of interop between CSV.jl and DataPipes.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CSV | |
using DataPipes | |
using SplitApplyCombine | |
csv = """ | |
x,y,z | |
1,3,5 | |
1,2,4 | |
2,4,1 | |
""" | |
# We use `IOBuffer(csv)` in order to explain to `CSV.File` that provided string is a content. | |
# Otherwise it would be treated as a file name. | |
# This example reads data from csv and calculates number of occurences of `x` key. | |
@p begin | |
IOBuffer(csv) | |
CSV.File(↑) | |
group(_.x) | |
map(length) | |
end | |
# Result is | |
# 2-element Dictionaries.Dictionary{Any, Int64} | |
# 1 │ 2 | |
# 2 │ 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment