Skip to content

Commit 4ec34ed

Browse files
committed
Exportable
1 parent ed35b9a commit 4ec34ed

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

utils/import_python_official.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
sys.path.append(".")
1111
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
1313
from tidy_conf import load_conferences, fuzzy_match, merge_conferences
1414

1515

@@ -89,23 +89,38 @@ def main(year=None, base=""):
8989

9090
# Load the existing conference data
9191
df_yml = load_conferences()
92+
df_yml = df_yml.loc[pd.to_datetime(df_yml["start"]) > pd.Timestamp(datetime.now())]
9293
df_new = pd.DataFrame(columns=df_yml.columns)
9394

9495
# Parse your .ics file and only use future events in the current year
9596
df = ics_to_dataframe()
9697
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]
9899

99-
print(df)
100+
_, reverse_titles = load_title_mappings(reverse=False)
100101

101102
# 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")
109124

110125
# Fill in missing required fields
111126
df_new = fill_missing_required(df_new)

0 commit comments

Comments
 (0)