# Nigeria YouTube Influencers Analysis
This project discovers, collects, ranks, and validates data about the top 1,000 YouTube influencers in Nigeria. It uses the YouTube Data API to gather channel information and Python with pandas to check the quality, structure, and consistency of the resulting dataset.
## Project Objectives
The project verifies that the dataset:
- Contains exactly 1,000 records
- Contains the expected four columns
- Uses appropriate data types
- Contains unique YouTube channel names
- Is ready for further analysis
## Data Collection and Scraping
The `scrap.py` script collects the data using the YouTube Data API. It does not scrape web pages directly; it uses authorized API requests to:
1. Discover YouTube channels using Nigerian-related search queries
2. Remove duplicate channels using their channel IDs
3. Retrieve channel statistics, including subscribers, views, and videos
4. Filter channels using Nigerian country information and location-related keywords
5. Calculate additional metrics such as views per video
6. Rank channels by subscribers and total views
7. Export the top 1,000 channels to a CSV file
The script generates these files in the directory where it is executed:
```text
nigeria_youtube_candidates.csv
nigeria_top_1000_youtube_influencers.csv
```
### YouTube API Setup
The scraper requires a YouTube Data API v3 key.
1. Create or select a project in the Google Cloud Console.
2. Enable the **YouTube Data API v3**.
3. Create an API key.
4. Create a `.env` file in the project root.
5. Add the key to the `.env` file:
```text
YOUTUBE_API_KEY=your_api_key_here
```
Never commit `.env` or expose your API key publicly. Add `.env` to `.gitignore` before pushing the repository to GitHub.
### Run the Scraper
Activate the virtual environment and install the dependencies:
```bash
source .venv/bin/activate
pip install -r requirement.txt
```
Run the collection script from the project root:
```bash
python scrap.py
```
The script use …