How to Output holehe Results to a File: CSV Export and Redirection Guide
Use the --csv flag to automatically export holehe results to a timestamped CSV file, or redirect standard output to capture console results in a custom text file.
When running email reconnaissance with holehe, you often need to persist scan results for reporting, automation, or further analysis. According to the megadose/holehe source code, the tool provides two reliable methods for file output: a built-in CSV exporter activated by a command-line flag, and standard shell redirection for plain-text capture.
Using the Built-In CSV Exporter
The recommended approach leverages the --csv (or -C) flag defined in holehe/core.py at lines 92-94. This triggers the export_csv helper function (lines 54-65), which programmatically constructs a filename and writes structured data.
How the CSV Export Works
The export_csv function in holehe/core.py automatically generates a filename with this pattern:
holehe_<timestamp>_<email>_results.csv
Each result dictionary from the scan becomes a row in the CSV, preserving keys such as domain, exists, rateLimit, emailrecovery, phoneNumber, and others returned by individual modules.
Basic CSV Export Command
holehe user@example.com --csv
After completion, you'll see confirmation:
All results have been exported to holehe_1723987200_user@example.com_results.csv
The file appears in your current working directory and opens cleanly in Excel, LibreOffice Calc, or any data analysis tool.
CSV Export with Clean Console Output
When redirecting or logging, disable color codes and screen clearing for cleaner files:
holehe user@example.com --no-color --no-clear --csv
This combination ensures the CSV file is created while the terminal output remains readable without ANSI escape sequences.
Redirecting Standard Output to a File
For quick captures or when you need human-readable output rather than structured data, shell redirection captures exactly what appears in the terminal.
Basic Redirection
holehe user@example.com > holehe_user_example.txt
This preserves the formatted summary table produced by the print_result function in holehe/core.py, including color codes unless --no-color is specified.
Appending Multiple Scans
holehe first@example.com >> combined_results.txt
holehe second@example.com >> combined_results.txt
The >> operator appends rather than overwrites, building a cumulative log.
Clean Text for Documentation
holehe user@example.com --no-color --no-clear > report.txt
This produces plain text suitable for inclusion in security reports or ticket systems.
Renaming and Organizing CSV Files
Since holehe auto-generates filenames with timestamps, you may want to rename files for consistency:
holehe user@example.com --csv
mv holehe_*_user@example.com_results.csv investigations/january_scan.csv
For scripted workflows with predictable names:
TARGET="user@example.com"
holehe "$TARGET" --csv
LATEST=$(ls -t holehe_*_"${TARGET}"_results.csv | head -n1)
mv "$LATEST" custom_name.csv
Source Code Implementation Details
The CSV export functionality is implemented directly in holehe/core.py:
| Component | Location | Purpose |
|---|---|---|
--csv argument parser |
Lines 92-94 | Adds the -C/--csv flag to argparse |
export_csv function |
Lines 54-65 | Writes result list to disk with timestamped filename |
The export_csv function processes the results list returned by maincore, iterating through dictionaries and using Python's CSV writer to ensure proper escaping of special characters. This implementation guarantees that site responses with commas or quotes do not corrupt the output structure.
Comparison: CSV vs. Redirection
| Approach | Best For | Data Structure | Post-Processing |
|---|---|---|---|
--csv flag |
Analysis, automation, reporting | Structured, columnar | Easy with pandas, spreadsheets |
> redirection |
Quick notes, screenshots, sharing | Human-readable lines | Manual parsing or grep |
--csv + > |
Complete archival | Both formats simultaneously | Maximum flexibility |
Most security workflows benefit from using --csv as the primary capture method, with redirection reserved for logging or documentation purposes.
Summary
- Add
--csvto any holehe command to generate a machine-readable CSV file with a timestamped filename containing all scan results - Use
>or>>shell operators to capture formatted terminal output when you need quick, human-readable logs - Combine
--no-colorand--no-clearwith either method to eliminate ANSI codes and screen-clearing sequences - Reference
holehe/core.pylines 54-65 and 92-94 to understand the underlying CSV export implementation
Frequently Asked Questions
Can I specify a custom CSV filename?
No, holehe automatically generates filenames with timestamps to prevent overwrites. Rename the file after generation using mv, or wrap the command in a script that handles renaming programmatically.
Does CSV export work when scanning multiple emails at once?
Yes, the --csv flag functions normally with any input format, but each invocation produces a separate CSV file. Batch multiple scans in a shell loop if you need consolidated results.
What columns appear in the CSV output?
The CSV contains all keys from result dictionaries returned by site modules, including: domain, exists, rateLimit, emailrecovery, phoneNumber, others, profile, and source—though specific fields vary by target site implementation.
Can I export to JSON instead of CSV?
Not natively. The export_csv function in holehe/core.py handles only CSV format. For JSON output, redirect console results and pipe through a converter, or modify the source code to add a parallel export_json function following the same pattern as lines 54-65.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →