Skip to main content

Read a CSV file and write an XLSX file with optional formatting.

Project description

dhk.csv2xlsx

GitHub

Latest Version Python Versions

Downloads Per Day Downloads Per Week Downloads Per Month

Introduction

dhk.csv2xlsx is a Python command-line tool for reading a CSV file and writing an XLSX file with optional formatting. It leverages the Python standard library csv module and the XlsxWriter package.

Simple Installation

A pedestrian command for installing the package is given below. Alternatively, for a more rewarding installation exercise, see section Recommended Installation.

pip install dhk.csv2xlsx

Usage

$ csv2xlsx --help
usage: csv2xlsx [-h] [--settings-file SETTINGS_FILE] [--verbose] [--force]
                [--output OUTPUT_FILE]
                CSV_FILE

Read a CSV file and write an XLSX file.

positional arguments:
  CSV_FILE              CSV file

options:
  -h, --help            show this help message and exit
  --settings-file, -s SETTINGS_FILE
                        settings file; default: None
  --verbose, -v         verbose
  --force, -f           force; suppress prompts
  --output, -o OUTPUT_FILE
                        output file; default: CSV_FILE - .csv + .xlsx

Examples:

    csv2xlsx \
        CSV_FILE

    csv2xlsx \
        --settings-file SETTINGS_FILE \
        CSV_FILE

    csv2xlsx \
        --settings-file SETTINGS_FILE \
        --output OUTPUT \
        CSV_FILE

Recommended Installation

pyenv is a tool for installing multiple Python environments and controlling which one is in effect in the current shell.

pipx is a tool for installing and running Python applications in isolated environments.

Assuming these have been installed correctly...

Install Python Under pyenv

The version of Python under which this package was last developed and tested is stored in .python-version.

To capture this Python version to a shell variable, execute the commands below. PYTHON_VERSION should be set to something like 3.13.3.

PYTHON_VERSION="$(
    wget \
        -O - \
        https://raw.githubusercontent.com/DavidKiesel/python-csv2xlsx/refs/heads/main/.python-version
)"

echo "$PYTHON_VERSION"

To determine if the .python-version version of Python has already been installed under pyenv, execute the command below. If it has not been installed, then a warning message will be displayed.

PYENV_VERSION="$PYTHON_VERSION" \
python --version

If it has already been installed, then proceed to section Install Package Using pipx.

Otherwise, to install the given version of Python under pyenv, execute the command below.

pyenv install "$PYTHON_VERSION"

If the install was successful, then proceed to section Install Package Using pipx.

If instead there is a warning that the definition was not found, then you will need to upgrade pyenv.

If pyenv was installed through a package manager, then consider upgrading it through that package manager. For example, if pyenv was installed through brew, then execute the commands below.

brew update

brew upgrade pyenv

Alternatively, you could attempt to upgrade pyenv through the command below.

pyenv update

Once pyenv has been upgraded, to install the given version of Python under pyenv, execute the command below.

pyenv install "$PYTHON_VERSION"

Install Package Using pipx

Only proceed from here if the instructions in section Install Python Under pyenv have been completed successfully.

At this point, shell variable PYTHON_VERSION should already contain the appropriate Python version. If not, execute the commands below.

PYTHON_VERSION="$(
    wget \
        -O - \
        https://raw.githubusercontent.com/DavidKiesel/python-csv2xlsx/refs/heads/main/.python-version
)"

echo "$PYTHON_VERSION"

To install the package hosted at PyPI using pipx, execute the command below.

pipx \
    install \
    --python "$(PYENV_VERSION="$PYTHON_VERSION" pyenv which python3)" \
    dhk.csv2xlsx

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

dhk_csv2xlsx-1.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dhk_csv2xlsx-1.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file dhk_csv2xlsx-1.0.1.tar.gz.

File metadata

  • Download URL: dhk_csv2xlsx-1.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for dhk_csv2xlsx-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4e168c42a1cc94858beabf901a71c6eec5e992d24d1cd5289db5da3b6a25bc88
MD5 6a8ca7faa6934f38b40c09429fadaf80
BLAKE2b-256 c06b3b82fc8d04fe5b580c26f441a1a79ec11b57d6124e5b18657527103e86c8

See more details on using hashes here.

File details

Details for the file dhk_csv2xlsx-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dhk_csv2xlsx-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for dhk_csv2xlsx-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3f70fffde9c7914230952098f816ca3ef4daca8ae359dd05efee24c238de11
MD5 9fecfdd7a210acab6c5735130552816b
BLAKE2b-256 8f976fae2fbc0adc816c6dd93f436f0a03d12dd5a9c46e57831833cd7acf805a

See more details on using hashes here.

Supported by

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