Created
April 6, 2019 14:24
-
-
Save ourway/123f1b94c4e700e02177c2ef7f4e159c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.stream!("priv/repo/data/MCI_SECRET_prepaid/postpaid_Table.csv") | |
|> CSV.decode() | |
|> Enum.take(1) | |
|> Enum.map(fn row -> | |
{:ok, [state, city, _, num]} = row | |
changeset = | |
Red9.MSID.changeset( | |
%Red9.MSID{}, | |
%{ | |
is_prepaid: false, | |
state: | |
case state do | |
"" -> | |
"FLAT" | |
state -> | |
state | |
end, | |
city: | |
case city do | |
"" -> | |
"FLAT" | |
city -> | |
city | |
end, | |
num: num | |
} | |
) | |
if changeset.valid? == true do | |
changeset |> Red9.Repo.insert() | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment