Skip to content

Instantly share code, notes, and snippets.

@Arkoniak
Last active June 10, 2021 08:10
Show Gist options
  • Save Arkoniak/595594a55b4d439b4827a0c2831eb2d5 to your computer and use it in GitHub Desktop.
Save Arkoniak/595594a55b4d439b4827a0c2831eb2d5 to your computer and use it in GitHub Desktop.
Example of interop between CSV.jl and DataPipes.jl
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