File size: 1,238 Bytes
bbb5184
 
 
ae0db51
bbb5184
 
ae0db51
 
 
 
bbb5184
 
 
 
 
 
 
 
 
 
 
 
 
ae0db51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bbb5184
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
from dataclasses import dataclass


@dataclass
class Pasuram:
    prabandham_code: str
    azhwar_name: str
    prabandham_name: str


def get_standardized_azhwar_names() -> list[Pasuram]:
    """
    Get a list of azhwar names along with the pasurams they have authored in divya_prabandham
    """
    with open("./data/azhwars.json", "r", encoding="utf-8") as f:
        azhwars = json.load(f)  # FIXED
        header = azhwars[0]
        rows = azhwars[1:]
        final_azhwars = [Pasuram(**dict(zip(header, row))) for row in rows]

    return final_azhwars


def get_standardized_divya_desam_names() -> list[dict]:
    """
    Get a list of divya desam names in divya_prabandham
    """
    with open("./data/divya_desams.json", "r", encoding="utf-8") as f:
        divya_desams = json.load(f)  # FIXED

    selected_fields = [
        "title",
        "other_names",
        "name_ta",
        "alwars",
        "area",
        "state",
        "thirukolam",
        "direction",
        "sampradayam",
        "divya_desam",
    ]
    return [{key : row[key] for key in selected_fields if key in row} for row in divya_desams["pageProps"]["hits"]]


if __name__ == "__main__":
    print(get_standardized_azhwar_names())