Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove image ICAOs without matching DB entry #383

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions scripts/create_db_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,47 @@
logging.info("New ICAOs successfully saved in 'plane_images.csv' file.")
else:
logging.info("No new ICAOs. Nothing to do.")

logging.info(
"Check for removed ICAOs in DB files and also remove them from the images reference file..."
)

if images_df.shape[0] > plane_alert_df.shape[0]:
logging.info(
"Extra ICAOs found ({})".format(
images_df.shape[0] - plane_alert_df.shape[0]
)
)

extra_icao_df = pd.merge(
images_df, plane_alert_df, on="$ICAO", how="left", indicator=True
)

extra_icao_df = extra_icao_df.loc[
extra_icao_df["_merge"] == "left_only"
].index.tolist()
for item in extra_icao_df:
if "plane_images_df" in locals():
plane_images_df = plane_images_df.drop(item)
plane_images_df.to_csv(
"plane_images.csv",
mode="wb",
index=False,
header=True,
encoding="utf8",
lineterminator="\n",
)
else:
images_df = images_df.drop(item)
images_df.to_csv(
"plane_images.csv",
mode="wb",
index=False,
header=True,
encoding="utf8",
lineterminator="\n",
)
logging.info("Extra ICAOs successfully removed from 'plane_images.csv'")

else:
logging.info("No extra ICAOs. Nothing to do.")