-
Notifications
You must be signed in to change notification settings - Fork 31
/
check_james_planes.py
43 lines (34 loc) · 1.6 KB
/
check_james_planes.py
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
"""Check whether the interesting planes given by James in
https://github.com/sdr-enthusiasts/plane-alert-db/issues/24 are already in the main
databases.
"""
import pandas as pd
import logging
from james_planes import james_planes_df
logging.basicConfig(
format="%(asctime)s %(levelname)-8s [%(name)s] %(message)s", level=logging.INFO
)
if __name__ == "__main__":
logging.info("Reading 'plane-alert-db' csv file...")
main_df = pd.read_csv("plane-alert-db.csv")
logging.info("'plane-alert-db' csv file read successfully.")
logging.info("Reading the 'plane-alert-twitter-blocked' csv file...")
twitter_blocker_df = pd.read_csv("plane-alert-twitter-blocked.csv")
logging.info("'plane-alert-twitter-blocked' csv file read successfully.")
logging.info("Reading 'plane-alert-ukraine' csv file...")
ukraine_df = pd.read_csv("plane-alert-ukraine.csv")
logging.info("'plane-alert-ukraine' csv file read successfully.")
logging.info("Concatenating all the dataframes...")
main_df = pd.concat([main_df, twitter_blocker_df, ukraine_df])
logging.info("Concatenation done.")
logging.info(
f"Get new items in 'james-planes' database ({james_planes_df.shape[0]})..."
)
new_items = james_planes_df[~james_planes_df["$ICAO"].isin(main_df["$ICAO"])]
james_planes_df[~james_planes_df["$ICAO"].isin(main_df["$ICAO"])]["$ICAO"].iloc[0]
if new_items.empty:
logging.info("No new items found.")
else:
logging.info(f"New items found ({new_items.shape[0]}).")
logging.info(new_items)
new_items.to_csv("james-planes-new-items.csv", index=False)