How to use the pylightxl.readxl.readxl function in pylightxl

To help you get started, we’ve selected a few pylightxl 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 PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_SelectedSheetReading(self):
        try:
            db = readxl('test/testbook.xlsx', ('empty', 'types'))
        except ValueError:
            db = readxl('testbook.xlsx', ('empty', 'types'))
        db_ws_names = db.ws_names
        db_ws_names.sort()
        true_ws_names = ['empty', 'types']
        true_ws_names.sort()
        self.assertEqual(db_ws_names, true_ws_names)
github PydPiper / pylightxl / test / test_readxl.py View on Github external
columnletter2num, num2columnletters
except ModuleNotFoundError:
    import os, sys

    sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname('test_readxl'), '..')))

    from pylightxl.readxl import readxl
    from pylightxl.database import Database, Worksheet, address2index, index2address, \
        columnletter2num, num2columnletters

try:
    # running from top level
    DB = readxl('./test/testbook.xlsx')
except ValueError:
    # running within /test folder or in debug
    DB = readxl('./testbook.xlsx')


# TODO: add test for formula returning empty string  tag

class test_readxl_bad_input(TestCase):

    def test_bad_fn_type(self):
        with self.assertRaises(ValueError) as e:
            db = readxl(fn=1)
            self.assertEqual(e, 'Error - Incorrect file entry ({}).'.format('1'))

    def test_bad_fn_exist(self):
        with self.assertRaises(ValueError) as e:
            db = readxl('bad')
            self.assertEqual(e, 'Error - File ({}) does not exit.'.format('bad'))
github PydPiper / pylightxl / test / test_readxl.py View on Github external
try:
    from pylightxl.readxl import readxl
    from pylightxl.database import Database, Worksheet, address2index, index2address, \
        columnletter2num, num2columnletters
except ModuleNotFoundError:
    import os, sys

    sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname('test_readxl'), '..')))

    from pylightxl.readxl import readxl
    from pylightxl.database import Database, Worksheet, address2index, index2address, \
        columnletter2num, num2columnletters

try:
    # running from top level
    DB = readxl('./test/testbook.xlsx')
except ValueError:
    # running within /test folder or in debug
    DB = readxl('./testbook.xlsx')


# TODO: add test for formula returning empty string  tag

class test_readxl_bad_input(TestCase):

    def test_bad_fn_type(self):
        with self.assertRaises(ValueError) as e:
            db = readxl(fn=1)
            self.assertEqual(e, 'Error - Incorrect file entry ({}).'.format('1'))

    def test_bad_fn_exist(self):
        with self.assertRaises(ValueError) as e:
github PydPiper / pylightxl / test / test_integration.py View on Github external
def test_reading_written_ws(self):
        file_path = 'temporary_test_file.xlsx'
        db = Database()
        db.add_ws('new_ws', {})
        writexl(db, file_path)
        db = readxl(file_path)
        self.assertEqual(db.ws_names, ['new_ws'])
        remove(file_path)
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_SelectedSheetReading(self):
        try:
            db = readxl('test/testbook.xlsx', ('empty', 'types'))
        except ValueError:
            db = readxl('testbook.xlsx', ('empty', 'types'))
        db_ws_names = db.ws_names
        db_ws_names.sort()
        true_ws_names = ['empty', 'types']
        true_ws_names.sort()
        self.assertEqual(db_ws_names, true_ws_names)
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_bad_fn_ext(self):
        with self.assertRaises(ValueError) as e:
            try:
                db = readxl('test/test_readxl.py')
            except ValueError:
                db = readxl('test_readxl.py')
            self.assertEqual(e, 'Error - Incorrect Excel file extension ({}). '
                                'File extension supported: .xlsx .xlsm'.format('py'))
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_bad_fn_exist(self):
        with self.assertRaises(ValueError) as e:
            db = readxl('bad')
            self.assertEqual(e, 'Error - File ({}) does not exit.'.format('bad'))
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_bad_fn_ext(self):
        with self.assertRaises(ValueError) as e:
            try:
                db = readxl('test/test_readxl.py')
            except ValueError:
                db = readxl('test_readxl.py')
            self.assertEqual(e, 'Error - Incorrect Excel file extension ({}). '
                                'File extension supported: .xlsx .xlsm'.format('py'))
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_bad_fn_type(self):
        with self.assertRaises(ValueError) as e:
            db = readxl(fn=1)
            self.assertEqual(e, 'Error - Incorrect file entry ({}).'.format('1'))
github PydPiper / pylightxl / test / test_integration.py View on Github external
def test_reading_written_cells(self):
        file_path = 'temporary_test_file.xlsx'
        db = Database()
        db.add_ws('new_ws', {})
        ws = db.ws('new_ws')
        ws.update_index(row=4, col=2, val=42)
        writexl(db, file_path)
        db = readxl(file_path)
        self.assertEqual(db.ws('new_ws').index(4, 2), 42)
        remove(file_path)