# Checking Split.io Treatments Using Email Addresses

This Python script integrates Snowflake with Split.io to fetch IDs based on email addresses from Snowflake, check treatments using Split.io feature flags, and store the results in a CSV file.

## Features

- Fetch IDs (identity_id) from Snowflake for provided email addresses.
- Check treatments using retrieved IDs and Split.io feature flags.
- Parse email addresses from a CSV file.
- Save results to a CSV file.

## Prerequisites

Before running the script, make sure you have the following installed:

- Python 3.9
- `snowflake-connector-python` library
- `splitio` library
- `pandas` library
- `python-dotenv` library

## Usage

1. Navigate to the project directory:

    ```bash
    cd split_treatment_checking_via_email
    ```

2. Create a virtual environment (optional but recommended):

    ```bash
    python3 -m venv env
    ```

4. Activate the virtual environment:

    On Windows:

    ```bash
    .\env\Scripts\activate
    ```

    On macOS and Linux:

    ```bash
    source env/bin/activate
    ```
      
4. Install dependencies:

    ```bash
    pip install -r requirements.txt
    ```

5. Set up environment variables by copying the shadow file:
   
   ```bash
    cp .env.shadow .env
    ```
    
    Define the following variables:

    ```plaintext
   SNOWFLAKE_USER=<your_snowflake_username>
   SNOWFLAKE_PASSWORD=<your_snowflake_password>
   SNOWFLAKE_ACCOUNT=<your_snowflake_account>
   SNOWFLAKE_ACCOUNT=<your_snowflake_role>
   SNOWFLAKE_WAREHOUSE=<your_snowflake_warehouse>
   SNOWFLAKE_DATABASE=<your_snowflake_database>
   SNOWFLAKE_SCHEMA=<your_snowflake_schema>
   SNOWFLAKE_TABLE=<your_snowflake_table>
   SNOWFLAKE_PASSCODE=<your_snowflake_passcode>
   SPLIT_API_KEY=<your_split_api_key>
    ```

6. Run the script:

    ```bash
    python app.py -e email1@email.com,email2@email.com
    ```

    or

    ```bash
    python app.py -f input.csv
    ```

    Use `-s` option to save results to a CSV file:

    ```bash
    python main.py -e email1@email.com,email2@email.com -s output.csv
    ```