transposecsv: A small Python library to transpose large csv files that can't fit in memory.
Suppose you have an p x m matrix where your original data is m points samples with p features, or in m points in p dimensional space. Then we want the column space to be the features, that is, we'd like to consider the m x p data matrix. This small library is for performing this calculation on arbitrarily large csv files.
It works in the following way:
- Read in chunks that fit in memory
- Transpose those in memory (which is fast)
- Write each transposed chunk to a
.csvfile - Use
pasteto join the files horizontally (columnwise), this is why we don't need to save the index, since it will be the same as the columns of the original file.
This process outputs the m x p matrix, as desired. This is particularly useful for single-cell data, where expression matrices are often uploaded genewise, but you may want to work with machine learning models that learn cellwise :).
Installation
To install, run pip install transposecsv
How to use
The transpose operation is contained in a lazily-loaded Transpose class, so the transpose operation isn't started on initialization. For example:
from transposecsv import Transpose
transpose = Transpose(
file_name='massive_dataset.csv',
write_path='massive_dataset_T.csv',
chunksize=400, # Number of rows to read in at each iteration
# leave as default
# insep=',',
# outsep=',',
# chunksize=400,
# save_chunks=False,
# quiet=False,
)
transpose.compute()
Then to upload to S3, we would run
tranpose.upload(
bucket='braingeneersdev',
endpoint_url='https://s3.nautilus.optiputer.net',
aws_secret_key_id=secret,
aws_secret_access_key=access,
remote_name='jlehrer/massive_dataset_T.csv'
)
Metadata
Release files for transposecsv 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transposecsv-0.0.5.tar.gz | 15.0 kB | Without provenance | Details for transposecsv-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transposecsv-0.0.5-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for transposecsv-0.0.5-py2.py3-none-any.whl |
Total release size: 22.1 kB
Release files / transposecsv-0.0.5.tar.gz
| Download URL | transposecsv-0.0.5.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
274e0cb537d4eb7af51425eac03bf196f547e06caf0ead9815729a7675bdb947
|
|
BLAKE2b-256 checksum How to use checksums |
bcc6a04ee1c0604909b6f8602c27a59d28bac7199f8f901a2d3a9fd83bf6f88f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / transposecsv-0.0.5-py2.py3-none-any.whl
| Download URL | transposecsv-0.0.5-py2.py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6b730ffbe55490a5a95d2c72cdece9fa66a7c8cdaf82310494825c49b1d965c0
|
|
BLAKE2b-256 checksum How to use checksums |
dd10e8137a1cadbc9156a6cca35821ffee14367f40545e99befceed4db136205
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for transposecsv 0.0.5
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.