Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wmarquardt/cassandra-csv
A simple way to export cassandra query result to CSV format
https://github.com/wmarquardt/cassandra-csv
cassandra csv data python
Last synced: 3 months ago
JSON representation
A simple way to export cassandra query result to CSV format
- Host: GitHub
- URL: https://github.com/wmarquardt/cassandra-csv
- Owner: wmarquardt
- License: mit
- Created: 2019-04-12T00:38:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T01:17:12.000Z (12 months ago)
- Last Synced: 2024-10-15T11:58:11.035Z (3 months ago)
- Topics: cassandra, csv, data, python
- Language: Python
- Size: 20.5 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![code-style](https://img.shields.io/badge/codestyle-black-black)](https://github.com/psf/black)
# Cassandra CSV
Python package to export cassandra query result to CSV format.
Cassandra `COPY` function does not export data with **WHERE** clause. If you need to export cassandra query result to CSV format, just read the documentation below.## Install
```shell
$ pip install cassandra-csv
```## Usage
```python
from cassandra.cluster import Cluster
from cassandracsv import CassandraCsvcluster = Cluster()
cassandra_cluster = cluster.connect('database')result = cassandra_cluster.execute("""SELECT foo FROM bar WHERE foobar=2""")
CassandraCsv.export(
result,
[options]
)
```## Options
|Name| Type | Default | Description |
|--|--|--|--|
| **max_file_size** | int | 0 | max CSV file size (lines) the file will be splitted until complete entire resultset. Use 0 to export all result to just one file |
| **output_dir** | string | /tmp | full output path
| **filename** | string | export_file | file name (without extension)
| **separator** | string | , | string separator
| **with_header** | boolean | True | show file header (field name or alias, added direct on select using `as`)
| **create_subfolder** | boolean | False | create sulfolder to store files.