Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update_geoname_data #19

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions mix_tasks/update_geoname_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ defmodule Mix.Tasks.UpdateGeonameData do
The data source allCountries.txt clocks in at 1.5GB. Expect this to take a while.
"""
def run(_) do
# System.cmd("wget", [@allcountries_src, "-O", "/tmp/allCountries.zip"])
# System.cmd("unzip", ["/tmp/allCountries.zip", "-d", "/tmp"])
tmp_txt = Path.join(System.tmp_dir!(), "allCountries.txt")

process_geonames_file("/tmp/allCountries.txt")
unless File.exists?(tmp_txt) do
System.cmd("wget", [@allcountries_src, "-O", "/tmp/allCountries.zip"])
System.cmd("unzip", ["/tmp/allCountries.zip", "-d", "/tmp"])
end

process_geonames_file(tmp_txt)
end

defp process_geonames_file(filename) do
Expand Down