项目作者: fabriziomiano

项目描述 :
COVID-19 bar chart race HTML production to mongo DB
高级语言: Python
项目地址: git://github.com/fabriziomiano/barchartrace2mongo.git
创建时间: 2020-09-24T08:07:44Z
项目社区:https://github.com/fabriziomiano/barchartrace2mongo

开源协议:

下载


BCR2Mongo

What is this?

A simple script that reads the data from the CPD dataset
and, for a given variable name, creates video-tagged HTML str that is dumped to
a given mongodb collection.

How to use

The script needs a running instance of mongoDB and the relative environment
variables need to be set.

Setup

  • create and activate a virtual environment by following this
  • install the requirements in requirements.txt
  • create a .env file in the root directory of the repo and add the following
    variables (needed):
    • MONGO_URI=<uri>
    • DB_NAME=<db_name>
    • COLLECTION_NAME=<coll_name>

Additionally, ENV and COLLECTION_NAME-DEV to keep development environments
isolated.

N.B.: The environment variables are needed by the script to write the HTML string
to the DB, that will be read by COVIDashIT:

Run

Once the .env has been prepared, in a shell with an active virtual environment

(venv)$ python bcr2mongo.py --var <variable-name-as-per-DPC-dataset>

Expected Output

If all goes down well, the output of, e.g.

(venv)$ python bcr2mongo.py --var totale_positivi

will be

  1. 2020-09-25 09:19:34,694 - main - [INFO] - ====================
  2. 2020-09-25 09:19:34,694 - main - [INFO] - ENVIRONMENT: dev
  3. 2020-09-25 09:19:34,694 - main - [INFO] - Doing totale_positivi
  4. 2020-09-25 09:19:34,694 - Utils - [INFO] - Getting Data
  5. 2020-09-25 09:19:35,148 - Utils - [INFO] - Done getting data
  6. 2020-09-25 09:19:35,167 - Utils - [INFO] - Making BCR
  7. 2020-09-25 09:21:55,855 - Utils - [INFO] - Done making BCR
  8. 2020-09-25 09:21:55,979 - main - [INFO] - Writing to DB to collection barcharts-dev
  9. 2020-09-25 09:22:00,013 - main - [INFO] - Done
  10. 2020-09-25 09:22:00,014 - main - [INFO] - ====================

and a new entry on the db will be created

alt_text