How to Export Holehe Results to a CSV File: CLI and Python Methods

To export Holehe results to a CSV file, add the -C or --csv flag when running the holehe command, or call the export_csv() function programmatically from holehe/core.py.

Holehe is an OSINT tool by megadose/holehe that checks whether an email address is registered on various websites. While the tool displays colorful terminal output by default, it also provides a built-in mechanism to save structured results for later analysis. This guide explains how to use the CSV export functionality implemented in the core module.

Enabling CSV Export from the Command Line

The simplest way to export Holehe results to a CSV file is through the command-line interface. The feature is controlled by the --csv flag (short form -C) defined in the argument parser at lines 92‑93 of holehe/core.py.

When you append this flag to your command, Holehe executes the standard email checks across all modules, then writes the aggregated results to a CSV file before exiting.


# Scan an email address and export results to CSV

holehe -C target@example.com

# Alternative using the long form flag

holehe --csv target@example.com

After completing the asynchronous scans, the program outputs a confirmation message indicating the filename and exits. The file uses the naming convention holehe_<timestamp>_<email>_results.csv, where <timestamp> represents the Unix time (in seconds) at the moment of export.

Understanding the CSV Export Logic

The export functionality resides in the export_csv() function located at lines 54‑64 of holehe/core.py. This function triggers only when args.csvoutput evaluates to True, which occurs when you supply the CSV flag.

Internally, the function performs three operations:

  1. Filename generation – constructs the output name using the current Unix timestamp and target email address
  2. Header creation – extracts column names from the keys of the first result dictionary (data[0].keys())
  3. Data serialization – iterates through all results and writes them as rows using Python's csv.DictWriter

The file is always saved to the current working directory from which you invoked the command.

CSV File Structure and Data Fields

Each exported CSV contains the following columns derived directly from the module result dictionaries:

  • name – Internal module identifier (e.g., github, twitter)
  • domain – The service's primary domain (e.g., github.com)
  • rateLimit – Boolean indicating if the request encountered rate limiting
  • error – Boolean flag for unexpected module errors
  • exists – Boolean indicating whether the email is registered on the service
  • emailrecovery – Partially obfuscated recovery email address, if discoverable
  • phoneNumber – Partially obfuscated recovery phone number, if available
  • others – JSON-compatible dictionary containing additional metadata returned by specific modules

This structured format allows you to import results into spreadsheet applications, databases, or data analysis pipelines without parsing terminal color codes or log files.

Programmatic CSV Export in Python

You can also trigger CSV exports when integrating Holehe into custom Python scripts. The export_csv() function is importable from the core module and accepts the same data structures used internally.

import asyncio
import httpx
from holehe.core import (
    export_csv, 
    import_submodules, 
    get_functions
)

async def scan_and_export(email):
    # Configure arguments to mimic CLI behavior

    class Args:
        csvoutput = True          # Enable CSV export

        nocolor = True
        noclear = True
        onlyused = False
        nopasswordrecovery = False
        timeout = 10

    args = Args()
    
    # Load all checking modules

    modules = import_submodules("holehe.modules")
    websites = get_functions(modules, args)
    
    # Execute checks concurrently

    results = []
    async with httpx.AsyncClient(timeout=args.timeout) as client:
        for website in websites:
            await website(email, client, results)
    
    # Export to CSV using the same function as the CLI

    export_csv(results, args, email)
    print(f"Scan complete. CSV exported for {email}")

# Run the async function

asyncio.run(scan_and_export("target@example.com"))

This approach produces identical output files to the command-line method, following the same holehe_<timestamp>_<email>_results.csv naming pattern.

Summary

  • Use the -C or --csv flag when running holehe from the terminal to automatically generate a CSV file in the current directory.
  • File naming follows the pattern holehe_<timestamp>_<email>_results.csv based on Unix time and the target email address.
  • The export_csv() function in holehe/core.py (lines 54‑64) handles all serialization logic, extracting headers from result dictionary keys.
  • All eight result fields (name, domain, rateLimit, error, exists, emailrecovery, phoneNumber, others) are preserved in the export for comprehensive OSINT documentation.
  • Programmatic access requires setting args.csvoutput = True and passing your results list to export_csv() along with the arguments object and email string.

Frequently Asked Questions

What flag enables CSV export in Holehe?

Add the -C (short form) or --csv (long form) argument when executing the holehe command. This flag is defined in the argument parser at lines 92‑93 of holehe/core.py and sets the internal csvoutput attribute to True.

Where are CSV files saved when using Holehe?

CSV files are saved to the current working directory from which you invoked the command. The filename follows the pattern holehe_<timestamp>_<email>_results.csv, where the timestamp represents the Unix time at export and the email is the target address you scanned.

What columns are included in the Holehe CSV export?

The CSV contains eight columns derived from the result dictionaries: name, domain, rateLimit, error, exists, emailrecovery, phoneNumber, and others. These fields capture module identifiers, service domains, error states, registration status, recovery contact information, and additional metadata.

Can I use the CSV export function programmatically in Python?

Yes. Import export_csv from holehe/core.py and call it with your results list, arguments object (with csvoutput set to True), and target email string. This function (lines 54‑64) handles file creation, header writing, and data serialization exactly as the CLI implementation does.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →