NAME : Aishwarya Tonpe
HOW TO RUN THE CODE : Use command : pipenv run python assignment2.py --urls files.csv
BUGS AND ASSUMPTIONS :
- Assumed that the date time format does not change
- Assumed that data in every pdf will be first downloaded and then processed
- Assumed that its reasonable to use Google Maps API which needs API-key or open-cage API which also needs API key
- In case of Google API and Open-cage, only 2500 free requests are permitted per day
IMPORTANT FUNCTIONS :
-
get_day_hour_from_the_date(date_string):
- Converts a date string (
date_string) into day of the week (0=Monday, 1=Tuesday, ...) and hour. - Parses the date string to extract day and hour components.
- Returns a tuple
(day_of_week, hour).
- Converts a date string (
-
get_coordinates(location, api_key):
- Retrieves latitude and longitude coordinates for a given
locationusing a geocoding API (googlemapsin this case). api_key: API key used for geocoding.- Returns a tuple
(longitude, latitude).
- Retrieves latitude and longitude coordinates for a given
-
get_weather_code(date_string, location, api_key):
- Obtains weather information (e.g., weather code) for a specific
date_stringandlocation. - Calls
get_coordinatesto retrieve coordinates for the location. - Uses an external weather API (
open-meteo.com) to get weather data based on coordinates and date. - Returns the weather code corresponding to the specified time.
- Obtains weather information (e.g., weather code) for a specific
-
rank_locations(incident_data):
- Ranks locations based on the frequency of occurrence within
incident_data. - Utilizes
Counterto count occurrences of each location. - Assigns rankings to locations based on occurrence frequency.
- Ranks locations based on the frequency of occurrence within
-
rank_incidents(incident_data):
- Ranks incident types based on their frequency within
incident_data. - Uses
Counterto count occurrences of each incident type. - Assigns rankings to incident types based on occurrence frequency.
- Ranks incident types based on their frequency within
-
get_side_of_the_town(location, central_latitude, central_longitude, api_key):
- Determines the side of town (e.g., NE, NW, SE, SW) for a given
location. - Compares the location's coordinates with central coordinates to ascertain direction (North/South, East/West).
- Returns a string representing the side of town.
- Determines the side of town (e.g., NE, NW, SE, SW) for a given
-
get_emsstat(record, info):
- Checks if the incident record has an associated
EMSSTATevent. - Searches within
info(list of incident records) to find correspondingEMSSTATevents for the same location and date/time. - Returns
Trueif an associatedEMSSTATevent is found; otherwise, returnsFalse.
- Checks if the incident record has an associated