mteb
1import json
2from pathlib import Path
3
4import pandas as pd
5
6
7def load_data(file_path: Path) -> pd.DataFrame:
8file_path = Path(__file__).parent / "points"
9files = file_path.glob("*.jsonl")
10
11json_data = []
12for file in files:
13with open(file) as f:
14for line in f:
15json_data.append(json.loads(line))
16
17df = pd.DataFrame(json_data)
18return df
19
20
21def save_to_markdown(df: pd.DataFrame, file_path: Path) -> None:
22df = df.groupby("GitHub").sum().astype(int)
23# create a new column with the sum of the points
24df["Total"] = df.sum(axis=1)
25# sort the dataframe by the total points
26df = df.sort_values("Total", ascending=False)
27
28md = df.to_markdown()
29# add title
30md = f"# Points\n\n_Note_: this table is **autogenerated** and should not be edited. It is intended to get an overview of contributions.\n\n {md}"
31with open(file_path, "w") as f:
32f.write(md)
33
34
35if __name__ == "__main__":
36file_path = Path(__file__).parent / "points"
37save_path = Path(__file__).parent / "points_table.md"
38
39df = load_data(file_path)
40save_to_markdown(df, save_path)
41