Packages

This package is used for learning purposes on how to use 'mix' and 'hex' for sharing elixir code. Do NOT waste your time here. The License is MIT, but the project uses a private api.

Current section

Files

Jump to
cape lib snapshot.ex
Raw

lib/snapshot.ex

defmodule Snapshot do
@moduledoc ~S'''
Funzioni varie di test
'''
NimbleCSV.define(MyParser, separator: ";")
def mydir do
"/winshare/Dati-lx/agol_csv/"
end
def leggi_stream(nome_file) do
nome_file
# READ_AHEAD)
|> File.stream!(read_ahead: 1_000_000)
|> MyParser.parse_stream()
# |> Stream.map(fn [cod_staz, cod_grand, data_mis, valore, cod_valid, liv_validaz] ->
# %{
# cod_staz: :binary.copy(cod_staz),
# cod_grand: :binary.copy(cod_grand),
# data_mis: :binary.copy(data_mis),
# valore: String.to_float(valore),
# cod_valid: :binary.copy(cod_valid),
# liv_validaz: :binary.copy(liv_validaz)
# }
# end)
end
def files do
files("*.csv")
end
def files(estensione) do
Path.wildcard(Path.join(mydir(), estensione))
end
def elabora(stream, quanti \\ 200_000) do
stream
|> Stream.chunk_every(quanti)
|> Enum.each(fn lista ->
send(self(), %{count: Enum.count(lista)})
end)
end
def l0 do
files() |> Enum.reverse() |> hd
end
def ftok do
_x = "where=&objectIds=1&time="
{:ok, c} = File.read('./secret_esri_token.txt')
URI.decode_query(c)
end
def get_token do
Map.get(ftok(), "token")
end
end