Compare commits
54 Commits
latest
...
menu_scrap
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c83c092b6 | |||
| b069513d96 | |||
| b41f6ff737 | |||
| d5aaa27cb7 | |||
| 1b8ef493b8 | |||
| 9bf1db4f05 | |||
| 1e67a07845 | |||
| 2943eef179 | |||
| 9693de1842 | |||
| 7b7389bce7 | |||
| 86fd35915c | |||
| 742a194363 | |||
| 8c9d869a54 | |||
| d658f909c9 | |||
| 2c496defa8 | |||
| a5e5ec8f21 | |||
| 64ecf4c4a4 | |||
| ff3e07d60a | |||
| 8c079f99e0 | |||
| 0420bcd4dc | |||
| cb8611a44f | |||
|
|
d01de9dedb | ||
| 16ce2d888c | |||
| caadacf5d7 | |||
| 2125fcf2f5 | |||
| 0393b0ea94 | |||
|
|
f11c714743 | ||
| 092efa0024 | |||
| fbd1790d74 | |||
| 033abc37e0 | |||
| 7b7ff01ce5 | |||
| 8c15adf460 | |||
| 5b459c0a2b | |||
| 1e7197e17a | |||
| b8ed730c34 | |||
| 4345ef27b6 | |||
| 52fbe3d7f4 | |||
| ff9d6273bd | |||
| 959ec8ad80 | |||
| 4e0413dc12 | |||
| 69c1aff5be | |||
| c3f051ca81 | |||
| 52ddc45122 | |||
| 9de7bdb1a8 | |||
| 91017ee2ec | |||
| fb90f26fba | |||
| 07cc5ce2f6 | |||
| 0aa0a0a3f1 | |||
|
|
28058432c1 | ||
| d7db36df30 | |||
|
|
771569e93d | ||
|
|
e0c4738a70 | ||
|
|
577d8afa75 | ||
| 9e11f1de67 |
48
.gitignore
vendored
Normal file
48
.gitignore
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Miscellaneous
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
.atom/
|
||||||
|
.buildlog/
|
||||||
|
.history
|
||||||
|
.svn/
|
||||||
|
migrate_working_dir/
|
||||||
|
|
||||||
|
# IntelliJ related
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
|
# is commented out by default.
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Flutter/Dart/Pub related
|
||||||
|
**/doc/api/
|
||||||
|
**/ios/Flutter/.last_build_id
|
||||||
|
.dart_tool/
|
||||||
|
.flutter-plugins
|
||||||
|
.flutter-plugins-dependencies
|
||||||
|
.packages
|
||||||
|
.pub-cache/
|
||||||
|
.pub/
|
||||||
|
/build/
|
||||||
|
pubspec.lock
|
||||||
|
|
||||||
|
# Symbolication related
|
||||||
|
app.*.symbols
|
||||||
|
|
||||||
|
# Obfuscation related
|
||||||
|
app.*.map.json
|
||||||
|
|
||||||
|
# Android Studio will place build artifacts here
|
||||||
|
/android/app/debug
|
||||||
|
/android/app/profile
|
||||||
|
/android/app/release
|
||||||
|
|
||||||
|
# KDE Specific Files
|
||||||
|
.directory
|
||||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# IIITB_Menu Excel File Scraper Code
|
||||||
|
Code for building the bi-weekly food menu database for use in the web app.
|
||||||
|
Two files are created, one of them is the JSON database file `menu.json` and the other is the md5 hash of the json data `hash.txt`.
|
||||||
|
The app checks for update in hash and downloads the new menu file if required.
|
||||||
|
The menu stays persistently on the device's web cache allowing for offline app usage.
|
||||||
|
|
||||||
|
# Automation
|
||||||
|
The menu has to be downloaded from the shared Excel Online link as ODS, be loaded into pandas, save as CSV and pushed to this branch.
|
||||||
|
This will create a new release/file in the repo which are the sources for the web app.
|
||||||
40
menu.csv
Normal file
40
menu.csv
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
Unnamed: 0,Unnamed: 1,Unnamed: 2,Unnamed: 3,Unnamed: 4,Unnamed: 5,Unnamed: 6,Unnamed: 7,Unnamed: 8
|
||||||
|
, ,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY
|
||||||
|
, ,2024-11-04 00:00:00,2024-11-05 00:00:00,2024-11-06 00:00:00,2024-11-07 00:00:00,2024-11-08 00:00:00,2024-11-09 00:00:00,2024-11-10 00:00:00
|
||||||
|
, ,2024-11-11 00:00:00,2024-11-12 00:00:00,2024-11-13 00:00:00,2024-11-14 00:00:00,2024-11-15 00:00:00,2024-11-16 00:00:00,2024-11-17 00:00:00
|
||||||
|
BREAKFAST, , , , , , , ,
|
||||||
|
,BREAKFAST 1,IDLY,ALOO gobi PARATHA,masala Dosa/podi dosa,Veg uthappam,pesarattu with onion,bedmi puri,Aloo onion paratha
|
||||||
|
,BREAKFAST 2,Medu vada,Coleslaw Sandwich,Kesari bath without clove,Puli pongal,Masala Vada,Aloo sabzi,Veg sandwich
|
||||||
|
,SAMBAR OR KETCHUP,Veg sambar, ,sambar, Sambar,sambar,Semiya upma,
|
||||||
|
,CURD, ,peanut chutney, ,coconut chutney,, ,Tomato chutney
|
||||||
|
,CHUTNEY,Coconut chutney,curd,coconut chutney,,coconut chutney,Coconut Chutney,CURD
|
||||||
|
,EGG,Boiled egg,Fruits,egg bhurji ,Watermelon Juice,omelette,Fruits,
|
||||||
|
,JUICE/MILK SHAKE, ,, , , , ,
|
||||||
|
LUNCH, , , , , , , ,
|
||||||
|
,INDIAN BREAD,CHAPATHI,AJWANI CHAPATI,JEERA CHAPATI,Beetroot POORI,CORRIANDER CHAPATHI,Chapati,BHATURE
|
||||||
|
,VEG GRAVY,Black channa gravy,Gatta ki subji,Subz Lababdar,ALOO BHAJJI(normal style),Egg masala/ Soya masala,corn masala,PINDI CHOLE
|
||||||
|
,VEG DRY/ STARTERS,BHINDI kurkure,raw banana poriyal,Cabbage fry,chole masala dry,idly 65 with green chutney,Black channa dry,HARA BHARA KEBAB
|
||||||
|
,FLAVORED RICE,Puliogare,vangi bath,CURD RICE,TOMATO RICE,hyderabadi DUM BIRIYANI,masala bhat,tomato rice
|
||||||
|
,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE
|
||||||
|
,DAL,moong dal,Yellow dal Tadka,GREEN MOONG DAL,LASOONI DAL TADKA,Dal Panchmel,Rajma Masala,Masoor Dal
|
||||||
|
,SAMBAR OR RASAM,Tomato RASAM,Malbar Cucumber SAMBAR,PEPPER RASAM,Pumpkin Sambhar,TOMATO RASAM,Peanut gun powder with ghee,Garlic rasam
|
||||||
|
,CURD BASE,Curd,curd,Lemonade,Curd,curd,majjiga pulusu,Sweet Lassi
|
||||||
|
,SALAD/SPROUTS,RED PASTA SALAD,ALOO CHANA CHAT,Sprout salad,Corn Capsicum Slad,dry chole,Tomato Green Salad,ONION\CHILLI\LEMON
|
||||||
|
,SWEETS,Chocolote/Vanilla Ice Cream,Strawberry milkshake,Mysore pak,Ice Cream,Assorted pastry,Moong Dal Halwa,Gulab Jamun
|
||||||
|
SNACKS, , , , , , , ,
|
||||||
|
,SNACKS,mix veg Bajji/ pakora,masala idly,veg puff,bhel puri,Dahi Papdi chat,Samosa,vada pav
|
||||||
|
,ACCOMPANIMENTS,green chutney,coconut chutney, ketchup,imli chutney ,green chutney,ketchup/imli,Mint chutney
|
||||||
|
,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK,TEA/COFFEE/MILK
|
||||||
|
DINNER, , , , , , , ,
|
||||||
|
,INDIAN BREAD,PUDINA CHAPATI,CHAPATI,coriander chapati,MASALA CHAPATI,Tandoori naan,paratha,METHI CHAPATHI
|
||||||
|
,VEG GRAVY,Baby corn & Mushroom masala gravy,baingan bharta,Veg Hyderbadi ,chole masala, ,Aloo Capsicum curry, Sabji lahori
|
||||||
|
,VEG DRY/ STARTERS,Mirchi ka Salan,masala aloo do pyaza,Rajma Ki tikki,Kadai Subzi,French fries,Gobi Manchurian dry ,
|
||||||
|
,FLAVORED RICE,Gobi biryani (biryani rice and gobi),Red sauce pasta live, ,bisibelle bhat & khara boondi,puliogere,schezwan noodles with sauce,Pudina rice
|
||||||
|
,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,PLAIN RICE,Plain rice,PLAIN RICE
|
||||||
|
,DAL,DAL PALAK,DAL MAKHANI,Salan,BLACK DAL TADKA,DAL TADKA,dal makhani ,DAL TADKA
|
||||||
|
,SAMBAR OR RASAM,Tamil nadu style sambar,Podi with ghee,Khara kozhumbu,tomato rasam,bhindi sambhar,drumstick Sambar,MANGALORE CUCUMBER SAMBAR
|
||||||
|
,CURD BASE,Veg raita,CURD,VEG RAITA,Curd,Curd,curd,Curd
|
||||||
|
,SALAD/SPROUTS,Russian salad,Salad,corn and capsicum salad,Red sauce PASTA Salad,VEG CORN SALAD,Green salad,GREEN SALAD
|
||||||
|
,SWEETS,SOOJI HALWA,Moong dal halwa,Rice kheer,Fruit custard,Coconut Laddu,rava laddu ,rasmalai
|
||||||
|
,PANEER, ,,Paneer Biryani(panner with a gravy and salan), ,paneer tikka masala , ,palak paneer
|
||||||
|
,CHICKEN, , ,CHICKEN BIRYANI, ,chicken Tikka Masala, ,chicken biryani
|
||||||
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
numpy
|
||||||
|
pandas
|
||||||
92
scrapeToJson.py
Normal file
92
scrapeToJson.py
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import pandas
|
||||||
|
import numpy
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
ALLDAYS = [
|
||||||
|
"SUNDAY",
|
||||||
|
"MONDAY",
|
||||||
|
"TUESDAY",
|
||||||
|
"WEDNESDAY",
|
||||||
|
"THURSDAY",
|
||||||
|
"FRIDAY",
|
||||||
|
"SATURDAY",
|
||||||
|
]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
#! TODO: Find a better XLSX import process. XLS IS ASS
|
||||||
|
# mainData = pandas.read_excel("menu.ods")
|
||||||
|
mainData = pandas.read_csv("menu.csv", skiprows=1)
|
||||||
|
mainData = mainData.replace("\xa0", numpy.nan)
|
||||||
|
breaksLoc = numpy.where(pandas.isna(mainData["\xa0"]).to_numpy() == False)[0]
|
||||||
|
breaksLoc = numpy.append(breaksLoc, [len(mainData)])
|
||||||
|
print(breaksLoc)
|
||||||
|
rowNames = mainData["\xa0.1"].to_numpy()
|
||||||
|
finalData = {"menu": {}, "dates": {}, "items": {}}
|
||||||
|
for sesNum, ses in enumerate(["bf", "ln", "sk", "dn"]):
|
||||||
|
finalData["items"][ses] = mainData["\xa0.1"].to_list()[
|
||||||
|
breaksLoc[sesNum] + 1 : breaksLoc[sesNum + 1]
|
||||||
|
]
|
||||||
|
for dayNumber, eachDay in enumerate(ALLDAYS):
|
||||||
|
print(eachDay)
|
||||||
|
for aDate in mainData[eachDay][: breaksLoc[0]]:
|
||||||
|
# print(type(aDate))
|
||||||
|
# aDate = str(aDate.to_pydatetime().date().strftime("%d-%m-%Y"))
|
||||||
|
aDate = str(
|
||||||
|
datetime.datetime.strptime(aDate, "%Y-%m-%d %H:%M:%S")
|
||||||
|
.date()
|
||||||
|
.strftime("%d-%m-%Y")
|
||||||
|
)
|
||||||
|
finalData["dates"][aDate] = str(dayNumber)
|
||||||
|
# print(finalData, rowNames, breaksLoc)
|
||||||
|
|
||||||
|
currentMenu = {"bf": {}, "ln": {}, "sk": {}, "dn": {}}
|
||||||
|
if eachDay in ["SUNDAY", "SATURDAY"]:
|
||||||
|
currentMenu["bfTimings"] = {"start": "07:45AM", "end": "10:00AM"}
|
||||||
|
currentMenu["lnTimings"] = {"start": "12:45PM", "end": "02:30PM"}
|
||||||
|
currentMenu["skTimings"] = {"start": "04:30PM", "end": "05:45PM"}
|
||||||
|
currentMenu["dnTimings"] = {"start": "07:30PM", "end": "09:30PM"}
|
||||||
|
else:
|
||||||
|
currentMenu["bfTimings"] = {"start": "07:30AM", "end": "09:45AM"}
|
||||||
|
currentMenu["lnTimings"] = {"start": "12:30PM", "end": "02:15PM"}
|
||||||
|
currentMenu["skTimings"] = {"start": "04:30PM", "end": "05:45PM"}
|
||||||
|
currentMenu["dnTimings"] = {"start": "07:30PM", "end": "09:30PM"}
|
||||||
|
|
||||||
|
for i, ses in enumerate(["BREAKFAST", "LUNCH", "SNACKS", "DINNER"]):
|
||||||
|
# print(ses)
|
||||||
|
for item in rowNames[breaksLoc[i] + 1 : breaksLoc[i + 1]]:
|
||||||
|
part = (
|
||||||
|
mainData.loc[breaksLoc[i] + 1 : breaksLoc[i + 1]]
|
||||||
|
.loc[mainData[" .1"] == item][eachDay]
|
||||||
|
.item()
|
||||||
|
)
|
||||||
|
if isinstance(part, float) and (part is numpy.nan):
|
||||||
|
part = "MT"
|
||||||
|
if part.strip() == "":
|
||||||
|
part = "MT"
|
||||||
|
|
||||||
|
# print(f"{item}: {part}")
|
||||||
|
if (
|
||||||
|
"egg" in part.strip().lower()
|
||||||
|
or "omlet" in part.strip().lower()
|
||||||
|
or "omelet" in part.strip().lower()
|
||||||
|
):
|
||||||
|
print(f"EGG Found, {part} at {ses}")
|
||||||
|
eggy = "EGG"
|
||||||
|
elif "chicken" in part.strip().lower():
|
||||||
|
eggy = "NON"
|
||||||
|
print(f"Chicken Found, {part} at {ses}")
|
||||||
|
else:
|
||||||
|
eggy = "VEG"
|
||||||
|
currentMenu[list(currentMenu.keys())[i]][item] = {
|
||||||
|
"name": part.strip().title(),
|
||||||
|
"eggy": eggy,
|
||||||
|
}
|
||||||
|
# print()
|
||||||
|
finalData["menu"][dayNumber] = currentMenu
|
||||||
|
# print(finalData)
|
||||||
|
with open("out.json", "w+") as jsonWriter:
|
||||||
|
json.dump(finalData, jsonWriter)
|
||||||
|
with open("out.txt", "w+") as hashWriter:
|
||||||
|
hashWriter.write(hashlib.md5(json.dumps(finalData).encode("utf-8")).hexdigest())
|
||||||
Reference in New Issue
Block a user