This Python project implements a names ranking system using the IBGE API. It fetches and analyzes data to provide insights into the frequency of names in Brazil, supporting various parameters such as location, sex, and time periods.
Report Bug
·
Request Feature
Table of Contents
This project is designed to help you analyze and rank names using the IBGE API. The program utilizes multiprocessing, leveraging parallelism with the available CPU cores, to enhance performance during data retrieval. Additionally, by incorporating Redis as a caching mechanism, the system achieves an average speed improvement of up to 300%, making the ranking process more efficient and responsive.
- Python: You can download and install Python from Python's official website.
- Redis (Optional): If you want to take advantage of caching for optimized performance, you can install Redis. You can download Redis from Redis's official website or use package managers like
apt
orbrew
:
# Example for Debian-based systems
sudo apt-get update
sudo apt-get install redis-server
- Requirements.txt
pip install -r requirements.txt
- Clone the repo
git clone https://github.com/gregoryfiel/ranking-names-ibge.git
- Run the script:
python main.py --nomes --localidade SP --sexo M --decada 1980
To use this names ranking system, follow these steps:
Create a file named nomes.json
in the project directory and list the names you want to rank. If not provided, the script will use a default set of names for a general ranking:
["Joao", "Maria", "Carlos", "Ana"]
If you prepared a list of names in nomes.json
, you can use the follow command:
python main.py --nomes
If not, you can simply call
python main.py
(A basic list of names has already been provided for exploring the code.)
Customize the ranking criteria with some flags according to your preferences:
python main.py --localidade SP --sexo M --decada 1980
- Additional options can be used to refine the ranking:
- --localidade: Filter by location (e.g., SP for São Paulo).
- --sexo: Filter by sex (e.g., M for male).
- --decada: Filter by decade (e.g., 1980).
Adjust optional settings to suit your needs:
--retryTimeout 3 15
- --retryTimeout: Set the number of retry attempts and the API request timeout in seconds (e.g., --retryTimeout 3 10 for 3 retries and a timeout of 10 seconds).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Gregory - @twitter_handle
Project Link: https://github.com/gregoryfiel/ranking-names-IBGE
- Thanks to Ilegra for providing this opportunity to learn by doing.
- Thanks to the IBGE API for providing valuable data.
- Special mention to the Clean Code principles for code maintainability.