-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
28 lines (24 loc) · 971 Bytes
/
main.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
import pandas as pd
from pathlib import Path
from argparse import ArgumentParser
from backbone import generate_merged_csv, read_data, find_ingredients
import warnings
warnings.filterwarnings("ignore")
ar = ArgumentParser()
ar.add_argument("-p", help="Path to dataset", default="/media/hdd/Datasets/culinarydb")
ar.add_argument("-l", help="Only list all ingredients present", action="store_true")
ar.add_argument("-i", help="Comma separated list of items to add", required=True)
ar.add_argument("-e", help="Comma separated list of items to exclude")
ar.add_argument("-f", help="Find exact name")
ap = ar.parse_args()
print("Reading data")
main_path = Path(ap.p)/"flattened_recipies.csv"
print("Loaded data")
# Check if database exists, if not then create
if not Path.exists(main_path): generate_merged_csv(ap.p)
# Read it
df = pd.read_csv(main_path)
if ap.l: print(list(df.columns)[3:-1])
if ap.f!= None: find_ingredients(df, ap.f)
else:
read_data(df, ap.i, ap.e)