Worked on getting reading persistence running
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
-133513
File diff suppressed because one or more lines are too long
+16
-1
@@ -33,7 +33,20 @@ defmodule Casebot do
|
||||
end
|
||||
|
||||
def run() do
|
||||
#master_data = ensure_file()
|
||||
|
||||
name = get_name()
|
||||
master_data = ensure_file(name) |> CSV.init_master_data()
|
||||
master_loop(master_data)
|
||||
|
||||
end
|
||||
|
||||
def get_name() do
|
||||
name = IO.gets("Enter route name: ")
|
||||
if !String.ends_with?(name, ".csv") do
|
||||
name
|
||||
else
|
||||
name <> ".csv"
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_file(path \\ "persist.csv") do
|
||||
@@ -44,6 +57,8 @@ defmodule Casebot do
|
||||
path
|
||||
end
|
||||
|
||||
|
||||
|
||||
def add_to_master(entry, master_data) do
|
||||
|
||||
end
|
||||
|
||||
+11
-1
@@ -1,8 +1,18 @@
|
||||
defmodule Casebot.CSV do
|
||||
def rows(path) do
|
||||
|
||||
@doc"""
|
||||
Returns a list of strings representing the CSV file. Each list
|
||||
"""
|
||||
def rows(path\\ "persist.csv") do
|
||||
path
|
||||
|> File.read!()
|
||||
#|> String.trim()
|
||||
|> NimbleCSV.RFC4180.parse_string(skip_headers: false)
|
||||
|> Enum.map(fn row -> Enum.map(row, &:binary.copy/1) |> List.to_tuple() end)
|
||||
|> Enum.map(String.trim)
|
||||
end
|
||||
|
||||
def init_master_data(filepath) do
|
||||
raw_data = CSV.rows(filepath)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user