From 5c78ebb72a948f6202b3e2bce72f834494ace788 Mon Sep 17 00:00:00 2001 From: Mali Akmanalp Date: Wed, 15 Jul 2015 00:15:20 -0400 Subject: [PATCH] Add spanish names --- colombia/dataset_tools.py | 6 ++++++ colombia/import.py | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/colombia/dataset_tools.py b/colombia/dataset_tools.py index 43d4106..5d4abe6 100644 --- a/colombia/dataset_tools.py +++ b/colombia/dataset_tools.py @@ -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) diff --git a/colombia/import.py b/colombia/import.py index 98e7c57..630301c 100644 --- a/colombia/import.py +++ b/colombia/import.py @@ -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() @@ -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)