How to use the pyexcel.internal.sheets.formatters.to_format function in pyexcel

To help you get started, we’ve selected a few pyexcel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_string_2_int_format(self):
        value = "11"
        n_value = formatters.to_format(int, value)
        assert n_value == 11
        value = "11.11111"
        n_value = formatters.to_format(int, value)
        assert n_value == 11
        value = "abc"
        n_value = formatters.to_format(int, value)
        assert n_value == value
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_date_conversion(self):
        d = datetime.datetime.now()
        new_d = formatters.to_format(datetime.datetime, d)
        assert d == new_d
        new_d = formatters.to_format(str, d)
        assert d.strftime("%d/%m/%y") == new_d
        new_d = formatters.to_format(bool, d)
        assert d == new_d
        t = datetime.time(11, 11, 11)
        new_t = formatters.to_format(datetime.datetime, t)
        assert t == new_t
        new_t = formatters.to_format(str, t)
        assert t.strftime("%H:%M:%S") == new_t
        new_t = formatters.to_format(bool, t)
        assert t == new_t
        bad = "bad"
        new_d = formatters.to_format(str, bad)
        assert bad == new_d
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_date_conversion(self):
        d = datetime.datetime.now()
        new_d = formatters.to_format(datetime.datetime, d)
        assert d == new_d
        new_d = formatters.to_format(str, d)
        assert d.strftime("%d/%m/%y") == new_d
        new_d = formatters.to_format(bool, d)
        assert d == new_d
        t = datetime.time(11, 11, 11)
        new_t = formatters.to_format(datetime.datetime, t)
        assert t == new_t
        new_t = formatters.to_format(str, t)
        assert t.strftime("%H:%M:%S") == new_t
        new_t = formatters.to_format(bool, t)
        assert t == new_t
        bad = "bad"
        new_d = formatters.to_format(str, bad)
        assert bad == new_d
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_date_conversion(self):
        d = datetime.datetime.now()
        new_d = formatters.to_format(datetime.datetime, d)
        assert d == new_d
        new_d = formatters.to_format(str, d)
        assert d.strftime("%d/%m/%y") == new_d
        new_d = formatters.to_format(bool, d)
        assert d == new_d
        t = datetime.time(11, 11, 11)
        new_t = formatters.to_format(datetime.datetime, t)
        assert t == new_t
        new_t = formatters.to_format(str, t)
        assert t.strftime("%H:%M:%S") == new_t
        new_t = formatters.to_format(bool, t)
        assert t == new_t
        bad = "bad"
        new_d = formatters.to_format(str, bad)
        assert bad == new_d
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_date_conversion(self):
        d = datetime.datetime.now()
        new_d = formatters.to_format(datetime.datetime, d)
        assert d == new_d
        new_d = formatters.to_format(str, d)
        assert d.strftime("%d/%m/%y") == new_d
        new_d = formatters.to_format(bool, d)
        assert d == new_d
        t = datetime.time(11, 11, 11)
        new_t = formatters.to_format(datetime.datetime, t)
        assert t == new_t
        new_t = formatters.to_format(str, t)
        assert t.strftime("%H:%M:%S") == new_t
        new_t = formatters.to_format(bool, t)
        assert t == new_t
        bad = "bad"
        new_d = formatters.to_format(str, bad)
        assert bad == new_d
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_int_2_float_format(self):
        value = 11
        n_value = formatters.to_format(float, value)
        assert type(n_value) == float
        assert n_value == value
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_int_2_string_format(self):
        value = 11
        n_value = formatters.to_format(str, value)
        assert n_value == "11"
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_date_format(self):
        d = "11-Jan-14"
        n_d = formatters.to_format(datetime.datetime, d)
        assert d == n_d
github pyexcel / pyexcel / tests / test_formatters.py View on Github external
def test_boolean_2_date(self):
        value = True
        n_value = formatters.to_format(datetime.datetime, value)
        assert type(n_value) == bool
        assert n_value == value
github pyexcel / pyexcel / pyexcel / plugins / renderers / _texttable.py View on Github external
def _cleanse_a_row(row):
    for item in row:
        if item == constants.DEFAULT_NA:
            yield " "
        else:
            yield to_format(str, item)