Delete key_to_name_map.py
Browse files- key_to_name_map.py +0 -31
key_to_name_map.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# coding: utf-8
|
3 |
-
|
4 |
-
"""Create a mapping from taxon keys to species names"""
|
5 |
-
|
6 |
-
import json
|
7 |
-
import os
|
8 |
-
from pathlib import Path
|
9 |
-
|
10 |
-
# System packages
|
11 |
-
import pandas as pd
|
12 |
-
|
13 |
-
# 3rd party packages
|
14 |
-
from dotenv import load_dotenv
|
15 |
-
|
16 |
-
# Load secrets and config from optional .env file
|
17 |
-
load_dotenv()
|
18 |
-
|
19 |
-
# Variable definitions
|
20 |
-
GLOBAL_MODEL_DIR = os.getenv("GLOBAL_MODEL_DIR")
|
21 |
-
moth_list = pd.read_csv(Path(GLOBAL_MODEL_DIR) / "gbif_moth_checklist_07242024.csv")
|
22 |
-
map_dict = {}
|
23 |
-
map_file = Path(GLOBAL_MODEL_DIR) / "categ_to_name_map.json"
|
24 |
-
|
25 |
-
# Build the dict
|
26 |
-
for _, row in moth_list.iterrows():
|
27 |
-
map_dict[int(row["acceptedTaxonKey"])] = row["species"]
|
28 |
-
|
29 |
-
# Save the dict
|
30 |
-
with open(map_file, "w") as file:
|
31 |
-
json.dump(map_dict, file, indent=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|