Skip to main content

CSV ElasticDictWriter

DictWriter, built on top of csv.DictWriter, that supports automatic extension of headers according to what data it receives. The result file always has a complete header (as defined by fieldnames) or it is extended if some new columns are introduced in the data. It always produces a valid CSV (missing columns are filled with blanks). It uses a series of cached writers / files that are merged into a single one with final set of columns on close()

Installation

The package may be installed via PIP:

pip install keboola.csvwriter

NOTE: If not using "with" statement, close() method must be called at the end of processing to get the result.

NOTE: Does not keep the order of rows added - the rows containing additional headers always come first:

Example:

from keboola.csvwriter import ElasticDictWriter
file = '/test/test.csv'
wr = ElasticDictWriter(file, ["a", "b" , "c"])
wr.writeheader()
wr.writerow({"a":1,"b":2})
wr.writerow({"b":2, "d":4})
wr.close()

leads to CSV with following content:

a b c d
2 4
1 2

May be also used with with statement to automatically close once finished:

from keboola.csvwriter import ElasticDictWriter
file = '/test/test.csv'
with ElasticDictWriter(file, ["a", "b" , "c"]) as wr:
    wr.writeheader()
    wr.writerow({"a":1,"b":2})
    wr.writerow({"b":2, "d":4})

# get final headers
final_header = wr.fieldnames

NOTE: The final column list is stored in fieldnames property:

columns = writer.fieldnames

Metadata

Release files for keboola.csvwriter 1.0.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 keboola.csvwriter 1.0.1
File Size Uploaded Provenance
keboola.csvwriter-1.0.1.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for keboola.csvwriter 1.0.1
File Interpreter ABI Platform
keboola.csvwriter-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / keboola.csvwriter-1.0.1.tar.gz

Download URL keboola.csvwriter-1.0.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2739dbe2808aa8e5e07f09a0183ba72e70af8125bc544ea85680e95331e6b945
BLAKE2b-256 checksum
How to use checksums
64b7ce1a3530856be8a14a3ee70d2a46393d489fe61daefe9cd14eed9503b17b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.2

Release files / keboola.csvwriter-1.0.1-py3-none-any.whl

Download URL keboola.csvwriter-1.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e20fba3bdfe15a9a08e82f25acc2273fa6632377b5958df8be57a8bbbb57ce34
BLAKE2b-256 checksum
How to use checksums
31b743acb5e6dfd1968842df1cef38ae66fde09af1e37b83b9a7e56edd37528b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.2

Security for keboola.csvwriter 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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