Skip to content

A python project that creates MongoDB collections of NBA statistics and data fetched from stats.nba.com

License

Notifications You must be signed in to change notification settings

Bastien-B/nba-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nba-mongo

A python project that creates MongoDB collections of NBA statistics and data fetched from stats.nba.com

The collections are designed to make advanced queries on teams or players as simple as possible.

Table of Contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

To install and use the project, you will need the following things:

Installing

Start by cloning the repository

git clone https://github.com/Bastien-B/nba-mongo.git

Create a python virtualenv in the repository

cd nba-mongo/
virtualenv venv

Activate your virtual environment and install the python packages dependencies

source venv/bin/activate
pip install -r requirements.txt

And this is it !

Configuring

Before generating the collections, you should edit the configuration file of your database: database.cfg

This file provides information such as:

  • host : the location of the MongoDB instance
  • port : the TCP port on which the MongoDB instance listens for client connections
  • db_name : the name of the database that will be created
  • teams_collection : the name of the teams collection that will be created
  • players_collection : the name of the players collection that will be created

Running

First, you have to make sure that a MongoDB instance is up and running at the location:port that you provided in the database.cfg file.

For instance, on your local machine (by default localhost:27017)

mongod --dbpath /path/to/your/databases

Now, simply run the main script of the project

python main.py

The process takes about 20 mins, and once it is done, a new MongoDB database should be created, containing two collections:

  • teams
  • players

nba-mongo run success

Success !

Here are some snapshots of the created collections, as seen on RoboMongo :

nba-mongo teams collection

nba-mongo players collection

Running the tests

The project comes with several unit tests located in the nba-mongo/tests/ folder. The tests are compatible with python test discovery.

To run them all, go to the project folder and call discover from command line

cd nba-mongo/
python -m unittest discover

Authors

  • Bastien Bessiere - Initial work - Bastien-B

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A python project that creates MongoDB collections of NBA statistics and data fetched from stats.nba.com

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages