DataMorph v0.0.7 DataMorph.Stream View Source
Link to this section Summary
Functions
Filter via regexp
and take count
Link to this section Functions
Filter via regexp
and take count
.
Examples
Filter lines by regexp:
iex> "name,iso\n" <>
...> "New Zealand,nz\n" <>
...> "United Kingdom,gb"
...> |> String.split("\n")
...> |> Stream.map(& &1)
...> |> DataMorph.Stream.filter_and_take(~r{King})
...> |> Enum.to_list
[
"United Kingdom,gb"
]
Take count lines:
iex> "name,iso\n" <>
...> "New Zealand,nz\n" <>
...> "United Kingdom,gb"
...> |> String.split("\n")
...> |> Stream.map(& &1)
...> |> DataMorph.Stream.filter_and_take(nil, 2)
...> |> Enum.to_list
[
"name,iso",
"New Zealand,nz"
]
Filter by regexp and take count lines:
iex> "name,iso\n" <>
...> "New Zealand,nz\n" <>
...> "United Kingdom,gb"
...> |> String.split("\n")
...> |> Stream.map(& &1)
...> |> DataMorph.Stream.filter_and_take(~r{d}, 1)
...> |> Enum.to_list
[
"New Zealand,nz"
]