|
9 | 9 |
|
10 | 10 | sys.path.append(".") |
11 | 11 | from tidy_conf.utils import fill_missing_required |
12 | | -from tidy_conf.yaml import write_df_yaml |
| 12 | +from tidy_conf.yaml import write_df_yaml, load_title_mappings |
13 | 13 | from tidy_conf import load_conferences, fuzzy_match, merge_conferences |
14 | 14 |
|
15 | 15 |
|
@@ -89,23 +89,38 @@ def main(year=None, base=""): |
89 | 89 |
|
90 | 90 | # Load the existing conference data |
91 | 91 | df_yml = load_conferences() |
| 92 | + df_yml = df_yml.loc[pd.to_datetime(df_yml["start"]) > pd.Timestamp(datetime.now())] |
92 | 93 | df_new = pd.DataFrame(columns=df_yml.columns) |
93 | 94 |
|
94 | 95 | # Parse your .ics file and only use future events in the current year |
95 | 96 | df = ics_to_dataframe() |
96 | 97 | df = df.loc[pd.to_datetime(df["start"]) > pd.Timestamp(datetime.now())] |
97 | | - df = df.loc[df["year"] == year] |
| 98 | + # df = df.loc[df["year"] == year] |
98 | 99 |
|
99 | | - print(df) |
| 100 | + _, reverse_titles = load_title_mappings(reverse=False) |
100 | 101 |
|
101 | 102 | # Fuzzy match the new data with the existing data |
102 | | - df_merged, df_remote = fuzzy_match(df_yml[df_yml["year"] == year], df) |
103 | | - df_merged["year"] = year |
104 | | - df_merged = df_merged.drop(["conference"], axis=1) |
105 | | - df_merged = merge_conferences(df_merged, df_remote) |
106 | | - |
107 | | - # Concatenate the new data with the existing data |
108 | | - df_new = pd.concat([df_new, df_merged], ignore_index=True) |
| 103 | + for y in range(year, year + 10): |
| 104 | + df_merged, df_remote = fuzzy_match(df_yml[df_yml["year"] == y], df.loc[df["year"] == y]) |
| 105 | + df_merged["year"] = year |
| 106 | + diff_idx = df_merged.index.difference(df_remote.index) |
| 107 | + print(df_merged.index, df_remote.index, diff_idx) |
| 108 | + df_missing = df_merged.loc[diff_idx, :].sort_values("start") |
| 109 | + df_merged = df_merged.drop(["conference"], axis=1) |
| 110 | + df_merged = merge_conferences(df_merged, df_remote) |
| 111 | + |
| 112 | + # Concatenate the new data with the existing data |
| 113 | + df_new = pd.concat([df_new, df_merged], ignore_index=True) |
| 114 | + for index, row in df_missing.iterrows(): |
| 115 | + out = f""" * name of the event: {reverse_titles.get(row["conference"], [row["conference"]])[0]} {row["year"]} |
| 116 | + * type of event: conference |
| 117 | + * focus on Python: yes |
| 118 | + * approximate number of attendees: Unknown |
| 119 | + * location (incl. country): {row["place"]} |
| 120 | + * dates/times/recurrence (incl. time zone): {row["date"]} ({row["timezone"] if isinstance(row["timezone"],str) else "UTC"}) |
| 121 | + * HTML link using the format <a href="http://url/">name of the event</a>: <a href="{row["link"]}">{row["conference"]}</a>""" |
| 122 | + with open("missing_conferences.txt", "a") as f: |
| 123 | + f.write(out + "\n\n") |
109 | 124 |
|
110 | 125 | # Fill in missing required fields |
111 | 126 | df_new = fill_missing_required(df_new) |
|
0 commit comments