Registry / serialization / csv2md

csv2md

JSON →
library1.6.0pypypi✓ verified 84d ago

csv2md is a command-line tool for converting CSV files into formatted Markdown tables. As of version 1.5.0, it is actively maintained with minor releases addressing features and bug fixes roughly every few months, ensuring correct escaping and handling of various CSV structures.

pip install csv2md
INSTALL
IMPORT
SIG · CSV2MD
C
csv2md
serializationpythonv1.6.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
import csv2md
from csv2md import convert

This quickstart demonstrates both command-line and programmatic usage. It creates a temporary CSV file and then uses `csv2md` to convert it. For CLI usage, ensure `csv2md` is installed and in your system's PATH. For programmatic use, the `convert` function expects a file-like object (e.g., `io.StringIO`).

import os import subprocess import tempfile import io # 1. Create a dummy CSV file for demonstration csv_content = """Name,Age,City Alice,30,New York Bob,24,London Charlie,22,"San Francisco|CA""" # Includes a pipe for testing escaping csv_file_path = None try: with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix=".csv", encoding="utf-8") as temp_csv_file: csv_file_path = temp_csv_file.name temp_csv_file.write(csv_content) temp_csv_file.flush() # Ensure content is written to disk print(f"--- CLI Usage (requires csv2md installed): {csv_file_path} ---") # This will only work if csv2md is installed and in PATH try: # Check if csv2md command is available subprocess.run(["csv2md", "--version"], capture_output=True, check=True) cmd_output = subprocess.run( ["csv2md", "--", csv_file_path], # Use -- to separate options from filename capture_output=True, text=True, check=True, encoding="utf-8" ) print(cmd_output.stdout.strip()) except FileNotFoundError: print("Skipping CLI example: 'csv2md' command not found. Please 'pip install csv2md'.") except subprocess.CalledProcessError as e: print(f"CLI Error: {e.stderr.strip()}") print(f"Output: {e.stdout.strip()}") print("\n--- Programmatic Usage (importing convert function) ---") try: from csv2md import convert # The 'convert' function expects a file-like object. input_stream = io.StringIO(csv_content) markdown_output = convert(input_stream) print(markdown_output.strip()) except ImportError: print("Error: 'csv2md' library not found. Please 'pip install csv2md'.") except Exception as e: print(f"Programmatic Error: {e}") finally: if csv_file_path and os.path.exists(csv_file_path): os.remove(csv_file_path) print(f"\nCleaned up temporary CSV: {csv_file_path}")
csv2md --version
Debug
Known issues
gotchaCSV cells containing pipe characters (`|`) were not escaped in Markdown output prior to `v1.4.0`, leading to malformed tables.
fix
Upgrade to `csv2md>=1.4.0` to ensure proper escaping of pipe characters in your Markdown tables.
affects: <1.4.0
gotchaThe `csv2md` library is primarily designed as a command-line tool. While programmatic use via `from csv2md import convert` is possible, the `convert` function expects a file-like object (like `io.StringIO` or an open file handle), not a file path string directly.
fix
When using `convert` programmatically, pass an `io.StringIO(csv_string)` object or an opened file handle as input, not a string representing the file path.
affects: All versions
gotchaEmpty lines within CSV files were not consistently handled across all versions, potentially leading to errors or unexpected output. As of `v1.5.0`, empty lines are now properly ignored.
fix
Upgrade to `csv2md>=1.5.0` to ensure robust handling and ignoring of empty lines in your CSV input.
affects: <1.5.0
Upgrade
Version history
1.6.0latest on PyPI · released Apr 25, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
csv2md — pip install csv2md · libregistry