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

> Export Holehe results to a CSV file easily using the CLI --csv flag or a Python script. Get your data in a structured format quickly.

- Repository: [Palenath/holehe](https://github.com/megadose/holehe)
- Tags: how-to-guide
- Published: 2026-08-28

---

**Use the `--csv` or `-C` flag when running Holehe from the command line to automatically generate a timestamped CSV file containing all scan results.**

Holehe is an open-source email enumeration tool developed by **megadose/holehe** that checks for account existence across hundreds of platforms. While it displays colored console output by default, you can export Holehe results to a CSV file for easier analysis, spreadsheet integration, and automated processing pipelines.

## Command-Line CSV Export with --csv

The simplest way to export Holehe results to a CSV file is using the built-in command-line flag. When you append `--csv` (or the short form `-C`) to your command, Holehe writes a file to your current working directory after completing all module checks.

```bash

# Basic scan with CSV export

holehe user@example.com --csv

# Using the short flag

holehe user@example.com -C

```

According to the source code in [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py), the `export_csv()` function generates filenames following the pattern `holehe_<timestamp>_<email>_results.csv`, where the timestamp represents the current Unix epoch time. This naming convention prevents overwrites when running multiple scans.

## How the CSV Exporter Works Under the Hood

### The export_csv() Implementation

In [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) at lines 54-64, the `export_csv()` function utilizes Python's built-in `csv.DictWriter` to serialize results. Each row in the output file represents a single checked platform, with columns corresponding to dictionary keys such as **domain**, **exists**, **emailrecovery**, and **phoneNumber** returned by each module.

### CLI Argument Registration

The `--csv` flag is registered in the argument parser within [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) at lines 92-94. When present, this boolean flag sets `args.csvoutput` to `True`, signaling the application to trigger file export after console output completes.

### Execution Flow Trigger

After all platform modules finish executing and the pretty-printed table renders to the terminal, the main execution flow at lines 29-30 conditionally invokes:

```python
export_csv(out, args, email)

```

The `out` parameter contains a list of dictionaries gathered from each site's response, making the CSV export a direct serialization of the internal results structure.

## Programmatic CSV Export in Python

For automation workflows, you can export Holehe results to a CSV file directly from Python without invoking the CLI wrapper. Import `export_csv` from `holehe.core` and invoke it with your results list:

```python
from holehe.core import export_csv

# Assuming 'out' is your list of result dictionaries from maincore()

args = type('Args', (), {'csvoutput': True})()
email = 'user@example.com'

export_csv(out, args, email)

```

This approach creates the same timestamped CSV file as the command-line interface, allowing you to integrate Holehe scans into larger data processing pipelines.

## Summary

- Use the `-C` or `--csv` flag to export Holehe results to a CSV file automatically after scanning completes
- The implementation in [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) uses `csv.DictWriter` to create timestamped files named `holehe_<timestamp>_<email>_results.csv`
- Each row represents one checked platform with columns for `domain`, `exists`, `emailrecovery`, and other metadata
- Programmatic access is available via the `export_csv()` function for custom Python scripts and automation

## Frequently Asked Questions

### What filename format does Holehe use for CSV exports?

Holehe generates files using the pattern `holehe_<timestamp>_<email>_results.csv` where the timestamp is the current Unix epoch time. This ensures each scan produces a unique filename in the current working directory.

### Can I specify a custom directory or filename for the CSV output?

The current implementation in [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) does not support custom filenames or paths through CLI arguments. The `export_csv()` function automatically constructs the filename and saves it to the directory where the command was executed.

### What data columns appear in the exported CSV file?

The CSV contains one row per checked platform with columns derived from the result dictionaries, including `domain`, `exists`, `emailrecovery`, `phoneNumber`, and others depending on what information each module returns about the target email address.

### Does the CSV export work when calling Holehe as a Python library?

Yes. When using Holehe programmatically, pass an object with a `csvoutput` attribute set to `True` as the `args` parameter to `export_csv()`, along with your results list and target email to trigger the file creation in your script's working directory.