Skip to main content

A Python package that eases the process of retrieving, organizing and altering data.

Project description

Fluxify

A Python package that eases the process of retrieving, organizing and altering data.

Required packages

  • pandas
  • PyYAML==5.2
  • imperium

Installation

pip install fluxify

Usage

Retrieve data from a simple CSV file

id,brand,price,state,published_at
938,Xaomi,390.90,used,2020-01-03 12:32:29
04593,iPhone,1299.90,new,2020-01-02 09:48:12

Implementation

from fluxify.mapper import Mapper
import yaml

# Could also be loaded from a file
yamlmapping = """
brand:
    col: 1
price:
    col: 2
state:
    col: 3
publish_date:
    col: 4
    transformations:
        - { transformer: 'date', in_format: '%Y-%m-%d %H:%M:%S', out_format: '%H:%M %d/%m/%Y' }
is_new:
    conditions:
        -
            condition: "subject['state'] == 'new'"
            returnOnSuccess: True
            returnOnFail: False
"""

Map = yaml.load(yamlmapping, Loader=yaml.FullLoader)
mapper = Mapper()
data = mapper.map('path/to/csvfile.csv', Map)
print(data)

Output

[
    {
        'brand': 'Xaomi',
        'price': '390.90',
        'state': 'used',
        'published_date': '12:32 03/01/2020'
        'is_new': False
    },
    {
        'brand': 'iPhone',
        'price': '1299.90',
        'state': 'new',
        'published_date': '09:48 02/01/2020'
        'is_new': True
    }
]

Supported formats

Format CSV JSON XML TXT
Supported YES YES YES NO

Transformers

Fluxify has built-in transformers that can alter/modify the data.

Function Arguments Description
number stringvalue Parses a string to an integer or float value
split delimiter, index Splits a string into parts with a delimiter and returns the splitted result if the index argument is not defined.
date in_format, out_format Let's you format a date string to the desired format.
replace search, new Replaces the search value with new value from string
boolean No arguments Parses a string to Boolean if the string contains [true
equipments_from_string delimiter Custom usage
options_from_string delimiter Custom usage

Exceptions

Fluxify has different Exception classes for different reasons They reside in the exceptions sub-package fluxify.exceptions

Class Arguments Description
ArgumentNotFoundException message This exception is raised whenever a argument is not found.
InvalidArgumentException message This exception is raised when a passed parameter/argument is invalid.
ConditionNotFoundException message This exception is raised when the "condition" key is not defined in the mapping.
UnsupportedTransformerException message This exception is raised when a transformer other than the ones defined above, is used.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fluxify, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size fluxify-0.0.3-py3-none-any.whl (10.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page