domdf_spreadsheet_tools

Tools for creating and formatting spreadsheets with Python and OpenPyXL.

Docs

Documentation Status

Tests

Travis Build Status Requirements Status CodeFactor Grade

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Anaconda

Conda - Package Version Conda - Platform

Other

License GitHub top language GitHub commits since tagged version GitHub last commit Maintenance

Installation

pip install domdf_spreadsheet_tools

First add the required channels

conda config --add channels http://conda.anaconda.org/domdfcoding
conda config --add channels http://conda.anaconda.org/conda-forge

Then install

conda install domdf_spreadsheet_tools
pip install git+https://github.com//domdf_spreadsheet_tools@master

domdf_spreadsheet_tools

Tools for creating and formatting spreadsheets with Python and OpenPyXL

domdf_spreadsheet_tools.append_to_xlsx(csv_input_file, xlsx_output_file, sheet_title=None, separator=',', overwrite=False, use_io=False, toFloats=False)[source]

Add CSV file to xlsx file as a new worksheet

Parameters
  • csv_input_file (str or pathlib.Path or os.PathLike) – filepath of CSV file to

  • xlsx_output_file (str or pathlib.Path or os.PathLike) – filepath of xlsx file

  • sheet_title (str, optional) – Title of sheet to append. Default is the value of csv_input_file

  • separator (str, optional) – Separator for reading CSV file. Default ,

  • overwrite (bool, optional) – Whether to overwrite the xlsx output file (i.e. create a new file containing just the new sheet). Default False

  • use_io (bool, optional) – Whether to use the io module. Default False

  • toFloats (bool, optional) – Whether to read strings with thousand separators as floats. Default False

Return type

None

domdf_spreadsheet_tools.format_header(ws, alignment_list, start_row=1, end_row=1)[source]

Format the alignment of the header rows of a worksheet

Parameters
  • ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format

  • alignment_list (Dict[str, str]) – dictionary of alignments (left, right, center) for each column letter

  • start_row (int, optional) – The row to start formatting on. Default 1

  • end_row (int, optional) – The row to end formatting on. Default 1

domdf_spreadsheet_tools.format_sheet(ws, number_format_list=None, width_list=None, alignment_list=None)[source]

Format columns of an xlsx worksheet

Parameters
  • ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format

  • number_format_list (Optional[Dict[str, str]]) – dictionary of number format strings for each column letter

  • width_list (Optional[Dict[str, float]]) – dictionary of widths for each column letter

  • alignment_list (Optional[Dict[str, str]]) – dictionary of alignments (left, right, or center) for each column letter

domdf_spreadsheet_tools.make_column_property_dict(indict, outdict=None, offset_dict=None, repeat=1, length=1)[source]

Generate property lists from integer values

Parameters
  • indict (dict) – Property values to add to the property dict

  • outdict (dict) – Dictionary of properties for each column letter

  • offset_dict

  • repeat (int, optional) – Default 1

  • length (int, optional) – Default 1

TODO: Finish this docstring; check usage in GunShotMatch

Returns

Return type

Downloading source code

PyMS source code resides on publicly accessible GitHub servers, and can be accessed from the following URL: https://github.com/domdfcoding/domdf_spreadsheet_tools/

If you have git installed, you can clone the repository with the following command:

$ git clone https://github.com/domdfcoding/domdf_spreadsheet_tools/
> Cloning into 'pyms'...
> remote: Enumerating objects: 47, done.
> remote: Counting objects: 100% (47/47), done.
> remote: Compressing objects: 100% (41/41), done.
> remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
> Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
> Resolving deltas: 100% (66/66), done.
Alternatively, the code can be downloaded in a ‘zip’ file by clicking:
Clone or download –> Download Zip
Downloading a 'zip' file of the source code.

Downloading a ‘zip’ file of the source code

Building from source

To build the domdf_spreadsheet_tools package from source using setuptools, run the following command:

$ python3 setup.py sdist bdist_wheel

setuptools is configured using the file setup.py.

Different formats are available for built distributions

Format

Description

Notes

gztar

gzipped tar file (.tar.gz)

default on Unix

bztar

bzipped tar file (.tar.bz2)

xztar

bzipped tar file (.tar.bz2)

tar

tar file (.tar)

zip

zip file (.zip)

default on Windows

wininst

self-extracting ZIP file for Windows

msi

Microsoft Installer


setup.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# This file is managed by `git_helper`. Don't edit it directly
"""Setup script"""

# 3rd party
from setuptools import find_packages, setup

from __pkginfo__ import *  # pylint: disable=wildcard-import

setup(
		author=author,
		author_email=author_email,
		classifiers=classifiers,
		description=short_desc,
		entry_points=entry_points,
		extras_require=extras_require,
		include_package_data=True,
		install_requires=install_requires,
		license=__license__,
		long_description=long_description,
		name=pypi_name,
		packages=find_packages(exclude=("tests", "doc-source")),
		project_urls=project_urls,
		py_modules=py_modules,
		python_requires=">=3.6",
		url=web,
		version=__version__,
		keywords=keywords,
		zip_safe=False,

		)

View the Function Index or browse the Source Code.

Browse the GitHub Repository