Source code for Logs Analysis tool designed in python.
By Manuinder Sekhon
It is a reporting tool that prints out reports (in plain text) based on the questions below.
- What are the most popular three articles of all time?
- Who are the most popular article authors of all time?
- On which days did more than 1% of requests lead to errors?
This project runs in a virtual machine provided by Udacity. Download required dependencies from links below.
application.py
defines themain
function that gets database name and formats the data for display. It depends onhelpers
module to get data from the database.helpers.py
defines a classLog
that establishes the connection to the database.Log
defines required methods to fetch desired data. It automatically closes the connection to database upon program termination.output.txt
contains the expected output of the program.
- Install virtualbox.
- Install vagrant.
- Install python 3.x
$ sudo apt-get update
$ sudo apt-get install python3
- Setup and start the virtual machine
NOTE: This operation may take several minutes to complete.
$ unzip FSND-Virtual-Machine.zip
$ cd FSND-Virtual-Machine/vagrant
$ vagrant up
$ vagrant ssh
- Put this project and the extracted
newsdata.zip
in/vagrant
directory. - Load news data into your database.
psql -d news -f newsdata.sql
- Verify that database is correctly loaded by executing
psql -d news
and running\dt
. If you see three tablesauthors
,articles
andlog
, then you are good to go!
cd /vagrant/Logs-Analysis-Tool
python3 application.py
Open output.txt
for sample output.