forked from cemaden-educacao/WPD-MobileApp
GabrielTrettel
3 years ago
5 changed files with 11401 additions and 14 deletions
-
5739src/app/assets/cities_states.js
-
25src/app/components/SearchablePicker.js
-
45src/app/screens/RegisterScreen.js
-
5571utils/cities.csv
-
35utils/cities_to_JSON.py
5739
src/app/assets/cities_states.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
5571
utils/cities.csv
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,35 @@ |
|||||
|
import pandas as pd |
||||
|
|
||||
|
SEP = " " |
||||
|
NEW_LINE = "\n" |
||||
|
O_OBJ = "{" |
||||
|
C_OBJ = "}" |
||||
|
|
||||
|
def main(): |
||||
|
df = pd.read_csv("./cities.csv") |
||||
|
|
||||
|
uf_to_city = df.groupby(["state_code", "state"]) |
||||
|
JSON = "const states = [\n" |
||||
|
for name, _ in uf_to_city: |
||||
|
UF, state_name = name |
||||
|
JSON += "\t\t"+O_OBJ+ " value: \"" +UF+"\", " + "label: \"" + f"{state_name} ({UF})" + "\" " + C_OBJ + ",\n" |
||||
|
|
||||
|
JSON += "];" |
||||
|
|
||||
|
JSON += """\n\n\nconst statesToCities = {\n""" |
||||
|
|
||||
|
|
||||
|
for name, group in uf_to_city: |
||||
|
UF, state_name = name |
||||
|
JSON += "\t" + f"{UF} : " + O_OBJ + "\n\t\t" + "state_name: " + "\""+state_name+"\"," + NEW_LINE + "\t\tcities: [\n" |
||||
|
|
||||
|
for city in group.name: |
||||
|
JSON += "\t\t\t"+O_OBJ+ " value: \"" +city+"\", " + "label: \"" + city + "\" " + C_OBJ + ",\n" |
||||
|
|
||||
|
JSON += "\t\t]\n\t},\n" |
||||
|
JSON += "\n};" |
||||
|
JSON += "export {states, statesToCities}" |
||||
|
|
||||
|
print(JSON) |
||||
|
|
||||
|
main() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue