-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from gm3dmo/ipdb
Adding ipdb back to the mix
- Loading branch information
Showing
5 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
|
||
# read csv.py | ||
# read csv_file and create a country model for each row in the csv file | ||
# the csv_file has the format "id,name,alpha2,alpha3,country_code" | ||
# read countries.json | ||
|
||
from cmp.models import Country | ||
import json | ||
|
||
csv_file = "/tmp/countries.csv" | ||
from cmp.models import Country | ||
|
||
with open(csv_file, "r") as f: | ||
for line in f: | ||
line = line.strip() | ||
if line.startswith("#"): | ||
continue | ||
id, name, alpha2, alpha3, old_id, blah = line.split(",") | ||
c = Country(name=name, alpha2=alpha2, alpha3=alpha3, old_id=old_id) | ||
print(c) | ||
c.save() | ||
with open('countries.json') as f: | ||
data = json.load(f) | ||
for country in data: | ||
print(country['name']['common']) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ black # used to format code | |
whitenoise | ||
django-crispy-forms | ||
crispy-bootstrap5 | ||
ipdb |
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