Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
defmodule FileReader do
# Create a File.Stream and inspect each line
def by_line(path) do
File.stream!(path)
|> Stream.map(&(IO.inspect(&1)))
|> Stream.run
end
def bin_line(path) do
# Build the stream in binary instead for performance increase
case File.open(path) do
# File returns a tuple, {:ok,file}, if successful
{:ok, file} ->
IO.binstream(file, :line)
|> Stream.map(&(IO.inspect(&1)))
|> Stream.run
# And returns {:error,reason} if unsuccessful
{:error,reason} ->
# Use Erlang's format_error to return an error string
:file.format_error(reason)
end
end
end