Skip to main content

converts large CSV files into smaller, Pandas-compatible Parquet files

pip install dfcsv2parquet

Tested against Windows 10 / Python 3.10 / Anaconda

The convert2parquet function is used to convert large CSV files into smaller Parquet files. It offers several advantages such as reducing memory usage, improving processing speed, and optimizing data types for more efficient storage.

This function might be interesting for individuals or organizations working with large datasets in CSV format and looking for ways to optimize their data storage and processing. By converting CSV files to Parquet format, which is a columnar storage format, several benefits can be achieved:

Reduced Memory Usage:

Parquet files are highly compressed and store data in a columnar format, allowing for efficient memory utilization. This can significantly reduce the memory footprint compared to traditional row-based CSV files.

Improved Processing Speed:

Parquet files are designed for parallel processing and can be read in a highly efficient manner. By converting CSV files to Parquet, you can potentially achieve faster data ingestion and query performance.

Optimized Data Types:

The function includes a data type optimization step (optimize_dtypes) that aims to minimize the memory usage of the resulting Parquet files. It intelligently selects appropriate data types based on the actual data values, which can further enhance storage efficiency.

Categorical Data Optimization:

The function handles categorical columns efficiently by limiting the number of categories (categorylimit). It uses the union_categoricals function to merge categorical data from different chunks, reducing duplication and optimizing memory usage.

        Args:
            csv_file (str | None): Path to the input CSV file. Default is None.
            parquet_file (str | None): Path to the output Parquet file. Default is None.
            chunksize (int): Number of rows to read from the CSV file per chunk. Default is 1000000.
            categorylimit (int): The minimum number of categories in categorical columns. Default is 4.
            verbose (int | bool): Verbosity level. Set to 1 or True for verbose output, 0 or False for no output. Default is 1.
            zerolen_is_na (int | bool): Whether to treat zero-length strings as NaN values. Set to 1 or True to enable, 0 or False to disable. Default is 0.
            args: passed to pd.read_csv (doesn't work with the cli)
            kwargs: passed to pd.read_csv (doesn't work with the cli)

        Returns:
            None

        Examples:
            # Download the csv:
            https://github.com/hansalemaos/csv2parquet/raw/main/bigcsv.part03.rar
            https://github.com/hansalemaos/csv2parquet/raw/main/bigcsv.part02.rar
            https://github.com/hansalemaos/csv2parquet/raw/main/bigcsv.part01.rar
            # in Python


            from dfcsv2parquet import convert2parquet
            convert2parquet(csv_file=r"C:\bigcsv.csv",
                                            parquet_file=r'c:\parquettest4.pqt',

                                            chunksize=1000000,
                                            categorylimit=4,
                                            verbose=True,
                                            zerolen_is_na=False, )

            # CLI
            python.exe "...\__init__.py" --csv_file "C:\bigcsv.csv" --parquet_file  "c:\parquettest4.pqt" --chunksize 100000 --categorylimit 4 --verbose 1 --zerolen_is_na 1         

Metadata

Release files for dfcsv2parquet 0.10

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

Source distribution (sdist)

Source distribution for dfcsv2parquet 0.10
File Size Uploaded Provenance Actions
dfcsv2parquet-0.10.tar.gz 27.2 kB Without provenance Details for dfcsv2parquet-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dfcsv2parquet 0.10
File Interpreter ABI Platform Actions
dfcsv2parquet-0.10-py3-none-any.whl Python 3 none any Details for dfcsv2parquet-0.10-py3-none-any.whl

Total release size: 55.5 kB

Release files / dfcsv2parquet-0.10.tar.gz

Download URL dfcsv2parquet-0.10.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
022f318325d5af7fd264e0342bf3347fd217052f7aa3bf669df98e3e441ac0e4
BLAKE2b-256 checksum
How to use checksums
5f402a4e450f489cec72efa09f2ea2bfe87423354960407644663f4cc9e487f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / dfcsv2parquet-0.10-py3-none-any.whl

Download URL dfcsv2parquet-0.10-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1879355a5d016d4eedb906f24cdf826aa1313de0fb892bc130c3b8faa2978894
BLAKE2b-256 checksum
How to use checksums
3b4cc9249a328fe67b6625db05fb757c70eca39a32eabf7adfdf27a5b2c3a0fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for dfcsv2parquet 0.10

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

0.10 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