crime_searcher is a terminal application to search for crimes committed in Sacramento. Based on the dataset in the SacramentocrimeJanuary2006.csv file.
Use the package manager pip to install simple-colors, geopy, and geographiclib.
You might need to to make a new python environment to install it. You can find further information on how to make a python environment and activate it.
pip install simple-colors | pip install geographiclib | pip install geopy
Run the app.py
to start the program.
Remember to be in the same folder as the
app.py
file.
python app.py
First thing printed out is the menu.
--- Main Menu ---
Enter 1: Search for a crime
Enter 2: Report a crime
Enter 3: Find crimes in proximity
Enter -1: Quit
Please enter a number:
To search for a crime on a specific category you'd have to input 1
in the console.
The next being displayed is a list of categories with examples to search for.
--- Categories ---
Enter 1: Date and time '1/1/06 0:00'
Enter 2: Address '3108 OCCIDENTAL DR'
Enter 3: District '2'
Enter 4: Grid '508'
Enter 5: Crime description '10851(A)VC TAKE VEH W/O OWNER'
Enter 6: UCR NCIC CODE '2404'
Enter -1: Go back
Please enter a number:
For example input 1
to search by date and time. We will use the example.
Please enter a number: 1
Search: 1/1/06 0:00
The results would be as following:
...
Result 20:
cdatetime: 1/1/06 0:00
address: 5641 DORSET WAY
district: 4
beat: 4C
grid: 1225
crimedescr: 484J PC PUBLISH CARD INFO
ucr_ncic_code: 2605
latitude: 38.52459987
longitude: -121.5203609
Results: 20
The user can then choose if he/she wants to export the results in either HTML or JSON format.
--- Export Options ---
Enter 1: JSON format
Enter 2: HTML format
Enter -1: Don't export
Please enter a number:
If user chose to export the results, then he/she can find the files in output-files
folder.
The file will automatically get opened.
Tests can be found in test
folder and can be run as following.
Unittest supports simple test discovery.
python -m unittest discover -s test -p "*_test.py"
Discovers all files ending with:
_test.py
python -m unittest discover -s test -p "value_test.py"
Discovers a specific file:
value_test.py
value_test.py
gps_test.py
value.py
gps_test2.py
- In the application you should be able to search for crimes based on the data in the different columns in the dataset.
- The application should be able to take a gps point (lon-lat) and return a list of crimes made within a radius of 5 km.
- The data output should be readable (for normal users).
- The application should furthermore be able to add new records to the dataset. (this includes writing to the csv file.)
- The application should be able to export the whole dataset into json and html formats, and should be able to export search results in json and and html formats as well.