A Python-based tool designed for sales and marketing teams to automate the cleaning, deduplication, and synchronization of company lead data from CSV files.
- Dynamic Batch CSV Processing: Automatically ingests CSV files from a user-specified directory.
- CLI Flag Control: Configurable execution using named flags for flexible processing.
- Idempotent File Tracking: Ensures each file is only processed once using a persistent tracking system.
- Data Cleaning & Standardization:
- Standardizes company names by removing noise while preserving context.
- Validates phone numbers (e.g.,
+8801...patterns) and strips formatting for consistency. - Preserves data integrity by only removing confirmed noise.
- CRM Synchronization: Optional automated sync of cleaned rows to an external CRM API with built-in retry logic (3 attempts).
- Language: Python (>= 3.12)
- Data Processing:
pandas - Networking:
requests - Package Management:
uv - Testing:
pytestwithpytest-cov
- uv installed on your system.
-
Clone the repository:
git clone <repository-url> cd maps
-
Synchronize dependencies:
uv sync
Run the tool using uv run python main.py.
Process files from the default unprocessed/ directory:
uv run python main.pyProcess files from a custom directory:
uv run python main.py --path ./my_csvsTo enable CRM sync, provide the --crm flag along with the required API details:
uv run python main.py \
--crm \
--url "https://your-crm-api.com" \
--type "lead" \
--sentby "YourName"CRM Flags:
--crm: Enable the CRM synchronization workflow.--url: (Required with--crm) The base URL for the CRM API.--type: (Required with--crm) Thetypefield value for CRM entries.--sentby: (Required with--crm) ThesentByfield value for CRM entries.
main.py: Entry point for the CLI.cleaner.py: Core logic for CSV processing and validation.crm_client.py: API client for CRM integration.processed_files.txt: Persistent log of processed filenames.all.csv: Master archive of all ingested rows.rejects.csv: Log of rows that failed validation.
Execute the full test suite (including unit and integration tests):
PYTHONPATH=. uv run pytestGenerate a coverage report:
PYTHONPATH=. uv run pytest --cov=main --cov=cleaner --cov=crm_client[Add License Information Here]