Skip to main content

Simple formula support for CSV

Project description

ReadTheDocs PyPI-Server Coveralls Project generated with PyScaffold Coveralls

csvsheet

Simple formula support for CSV

Description

The aim of this project is to provide simple math capabilities to CSV files. The capabilities are reduced to be able to use python formulas in a cell. The formulas are evaluated using eval, so a basic sanitazion is done to avoid major risks, to do so, only math library can be used as well ass int, float and +|-|*||(|).

Command line usage

The command line requires a single compulsory arugment, the CSV fileto process:

csvsheet <file.csv> -o <output.csv> -d <delimiter> -q <quotechar> -m <equation_delimiter> -v -vv
csvsheet --help

The input file is required, if ‘-’ is used, stdin is used. The output file is optional, if not provided, the output will be printed to stdout. The delimiter is also optional, if not provided, the default delimiter is ,. The quotechar is also optional, if not provided, the default quotechar is . The equation delimiter is also optional, if not provided, the default equation delimiter is =.

The -v and -vv flags are optional, they are used to increase the verbosity of the output.

Read the extended docs for extra information.

Example

The following example shows how to use the command line:

csvsheet example.csv

If the contents of example.csv are:

item,result
Great,=1+2
Not so great,=math.pow(2, 3)

The output will be:

item,result
Great,3
Not so great,8.0

Python usage

The python usage is very simple, it is only required to import the csvsheet module and call the run function:

import csvsheet

csvsheet.run(["tests/test_a.csv"])

Making Changes & Contributing

This project uses pre-commit, please make sure to install it before making any changes:

pip install pre-commit
cd csvsheet
pre-commit install

It is a good idea to update the hooks to the latest version:

pre-commit autoupdate

Don’t forget to tell your contributors to also install and use pre-commit.

Note

This project has been set up using PyScaffold 4.4.1. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

csvsheet-0.1.2.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

csvsheet-0.1.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file csvsheet-0.1.2.tar.gz.

File metadata

  • Download URL: csvsheet-0.1.2.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for csvsheet-0.1.2.tar.gz
Algorithm Hash digest
SHA256 20ed27924ddba7b9d7575558044739701014ecc54f547c16e8f1f98f6645af84
MD5 7bf62ef8844addf301072344bb781d1d
BLAKE2b-256 01402d144a1b958e839fdf4e741609d705a72699b8fe47f7f71397f4968af49e

See more details on using hashes here.

File details

Details for the file csvsheet-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: csvsheet-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for csvsheet-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc1c72c5310a3bf90b3843c51c5513d05dfbff6020140699542bebe5133f6d7a
MD5 9337710613697e24ee7634560e5de2e0
BLAKE2b-256 ba5548e8b9cce67c5823a371c35d0220a55ed19e2248874aeac0a42f33a97d5c

See more details on using hashes here.

Supported by

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