Skip to content

Commit

Permalink
Add spanish names
Browse files Browse the repository at this point in the history
  • Loading branch information
makmanalp committed Jul 15, 2015
1 parent 180fffe commit 5c78ebb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions colombia/dataset_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def classification_to_models(classification, model):
m.id = index.item()
m.code = row["code"]
m.name_en = row["name"]
if "name_es" in row:
m.name_es = row["name_es"]
if "name_short_en" in row:
m.name_short_en = row["name_short_en"]
if "name_short_es" in row:
m.name_short_es = row["name_short_es"]
m.level = row["level"]
m.parent_id = row["parent_id"]
models.append(m)
Expand Down
8 changes: 8 additions & 0 deletions colombia/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from datasets import (trade4digit_department, industry4digit_department,
industry4digit_municipality, population, gdp)

import pandas as pd

if __name__ == "__main__":

app = create_app()
Expand All @@ -15,6 +17,12 @@
industry_classification,
location_classification)

df = pd.read_excel("/Users/makmana/classifications/product/HS/Mexico/in/Mexico Short Names Final.xlsx")
df = df[["code", "hs4_name_spanish", "Spanish Short Name", "hs4_name_en (original short name)"]]
df.columns = ["code", "name_es", "name_short_es", "name_short_en"]
df.code = df.code.astype(str).str.zfill(4)
product_classification.table = product_classification.table.merge(df, on="code", how="left")

products = classification_to_models(product_classification,
models.HSProduct)
db.session.add_all(products)
Expand Down

0 comments on commit 5c78ebb

Please sign in to comment.