Refactor code structure for improved readability and maintainability

This commit is contained in:
bolade
2025-10-06 12:57:08 +01:00
parent a2b3ceedbe
commit c199f5423a
6 changed files with 332 additions and 10 deletions
+7 -6
View File
@@ -13,7 +13,8 @@ logger = logging.getLogger(__name__)
# Import the schema
init_database()
#===================== Ingesting Original Data =====================#
# ===================== Ingesting Original Data =====================#
def parse_investor_names(investor_names_str):
"""Parse comma-separated investor names and return a list"""
if pd.isna(investor_names_str) or investor_names_str == "":
@@ -21,7 +22,9 @@ def parse_investor_names(investor_names_str):
# Split by comma and clean whitespace
# investors = [name.strip() for name in str(investor_names_str).split(",")]
investors = [clean_name(name.strip()) for name in str(investor_names_str).split(",")]
investors = [
clean_name(name.strip()) for name in str(investor_names_str).split(",")
]
return [investor for investor in investors if investor]
@@ -165,8 +168,8 @@ def ingest_data():
if not existing_investor:
investor = InvestorTable(
name=investor_name,
# description=clean_string(row.get("Business model", "")),
# geographic_focus=clean_string(row.get("HQ", "")),
description=clean_string(row.get("Business model", "")),
headquarters=clean_string(row.get("HQ", "")),
website=parse_website(str(row.get("Website", "")).strip()),
number_of_investments=clean_integer(
row.get("Number of investments")
@@ -305,8 +308,6 @@ def ingest_data():
session.close()
if __name__ == "__main__":
ingest_data()
# print(clean_name("A... Energi"))