Skip to main content

csv-to-yaml

Lightweight CSV to YAML and YAML to CSV converter.

Installation

pip install csv-to-yaml

Or with uv:

uv add csv-to-yaml

Requirements

  • Python >= 3.13
  • PyYAML >= 6.0

CLI Usage

# Convert CSV to YAML (output to stdout)
csv-to-yaml input.csv

# Convert YAML to CSV (output to stdout)
csv-to-yaml input.yaml

# Specify output file
csv-to-yaml input.csv -o output.yaml
csv-to-yaml input.yaml -o output.csv

# Explicitly specify output format
csv-to-yaml input.csv -f yaml
csv-to-yaml input.yaml -f csv

Python API

Convert CSV to YAML

from main import csv_to_yaml

# From file path
data = csv_to_yaml("data.csv")  # Returns list of dicts
yaml_str = csv_to_yaml("data.csv", as_string=True)  # Returns YAML string

# From string
csv_data = "name,age\nAlice,30\nBob,25"
data = csv_to_yaml(csv_data)

Convert YAML to CSV

from main import yaml_to_csv

# From file path
data = yaml_to_csv("data.yaml")  # Returns list of dicts
csv_str = yaml_to_csv("data.yaml", as_string=True)  # Returns CSV string

# From string
yaml_data = "- name: Alice\n  age: 30"
data = yaml_to_csv(yaml_data)

File-to-File Conversion

from main import csv_file_to_yaml_file, yaml_file_to_csv_file

csv_file_to_yaml_file("input.csv", "output.yaml")
yaml_file_to_csv_file("input.yaml", "output.csv")

Unicode Support

Full Unicode support including CJK characters:

csv_data = "이름,나이\n홍길동,30"
result = csv_to_yaml(csv_data)
# [{'이름': '홍길동', '나이': '30'}]

Development

# Install dev dependencies
uv sync

# Run tests
pytest

License

MIT

Metadata

Release files for csv-to-yaml 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-to-yaml 0.1.1
File Size Uploaded
csv_to_yaml-0.1.1.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csv-to-yaml 0.1.1
File Interpreter ABI Platform
csv_to_yaml-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / csv_to_yaml-0.1.1.tar.gz

Download URL csv_to_yaml-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c790a93dbddd9b4ffce774b62e9e579b97e3eba4dae538811dc4126b05f2f156
BLAKE2b-256 checksum
How to use checksums
3a085e98be38e3d545e195da660f2e5008f3b188a5e2809eca7800af0905a69a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release files / csv_to_yaml-0.1.1-py3-none-any.whl

Download URL csv_to_yaml-0.1.1-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4826e753c35ae4c7297d159c4354c43649e3605619ab95f6f70455206b5bcddc
BLAKE2b-256 checksum
How to use checksums
fe83ee2762d76c8712c430fffd5d14478325ff10e9f30b45dfed61182ba1765a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page