Skip to main content

Convert Python data structures to CSV format

Project description

csv-stringify

A Python package for converting data to CSV text format.

Installation

pip install csv-stringify

Usage

Basic Usage

from csv_stringify import stringify

output = stringify([
  ["1", "2", "3", "4"],
  ["a", "b", "c", "d"],
], header=False)

print(output)  # "1,2,3,4\na,b,c,d\n"

More Examples

from csv_stringify import stringify

# Basic usage
data = [["1", "2", "3"], ["a", "b", "c"]]
csv_string = stringify(data, header=False)
print(csv_string)  # "1,2,3\na,b,c\n"

# With headers
csv_string = stringify(data, columns=["A", "B", "C"])
print(csv_string)  # "A,B,C\n1,2,3\na,b,c\n"

# From dictionaries
data = [{"name": "John", "age": 25}]
csv_string = stringify(data)
print(csv_string)  # "name,age\nJohn,25\n"

API

stringify(data, **options)

Convert data to CSV string.

Parameters:

  • data: List of lists or list of dictionaries
  • columns: List of column names (optional)
  • header: Include header row (default: True)
  • delimiter: Field delimiter (default: ',')
  • quote_char: Quote character (default: '"')
  • quote_mode: Quoting mode (default: 'minimal')

Returns: CSV string

Requirements

  • Python 3.7+
  • No external dependencies

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csv_stringify-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

csv_stringify-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file csv_stringify-1.0.0.tar.gz.

File metadata

  • Download URL: csv_stringify-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for csv_stringify-1.0.0.tar.gz
Algorithm Hash digest
SHA256 055d8530b41ddcd5c705553f50915ec5d8cce61a4a7487a6c21152bbe54db47d
MD5 d4ce829e4f0d9ddf8caef45637b29596
BLAKE2b-256 973ee3b1e9059e1cb8e249313e05b2bed52f9771bea84d27a1698e55fd39d2e3

See more details on using hashes here.

File details

Details for the file csv_stringify-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: csv_stringify-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for csv_stringify-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96d5d2d803aafd53d62305471f1447324c9aac29aa22a8dcd8fe0d7e3693e57d
MD5 5be50aa99cadb0b4033f108ebdb0b097
BLAKE2b-256 763c55e4180f5828447506d4d403ba4e3a63446556858406d886eaa75204b759

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page