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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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