import pandas as pd

# Load the merged CSV
df = pd.read_csv("performance_target.csv")

# Sub-category mapping dictionary
sub_category_mapping = {
    1: "No of Technologies (IP, Licensing, Patents etc)",
    2: "Technology Products",
    3: "Publications, IPR and other Intellectual activities",
    4: "Increase in CPS Research Base",
    5: "Technology Business Incubator (TBI)",
    6: "Start-ups & Spin-off companies",
    7: "GCC - Grand Challenges & Competitions",
    8: "Promotion and Acceleration of Young and Aspiring technology entrepreneurs (PRAYAS)",
    9: "CPS-Entrepreneur In Residence (EIR)",
    10: "Dedicated Innovation Accelerator (DIAL)",
    11: "CPS-Seed Support System (CPS- SSS)",
    12: "Job Creation",
    13: "Graduate Fellowships",
    14: "Post Graduate Fellowships",
    15: "Doctoral Fellowships",
    16: "Faculty Fellowships",
    17: "Chair Professors",
    18: "Skill Development",
    19: "Postdoctoral Fellowships",
    20: "International Collaboration",
    21: "Resources of TIH",
    22: "Academic Institutions",
    23: "Business Enterprises",
    24: "NGOs",
    25: "Others",
    26: "Technologies Commercialised"
}

# Map the sub_category_id to sub_category_name
df['sub_category_name'] = df['sub_category_id'].map(sub_category_mapping)

# Reorder: place sub_category_name before sub_category_id
cols = df.columns.tolist()
cols.insert(cols.index('sub_category_id'), cols.pop(cols.index('sub_category_name')))
df = df[cols]

# Save to new CSV
df.to_csv("new_targets.csv", index=False)

print("✅ Done! Saved as merged_target_achieve_with_subcategory_names.csv")
