How to use the pylightxl.database.Worksheet 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_ws_init(self):
        ws = Worksheet(data={})
        self.assertEqual(ws._data, {})
        self.assertEqual(ws.maxrow, 0)
        self.assertEqual(ws.maxcol, 0)
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_size(self):
        ws = Worksheet({})
        self.assertEqual(ws.size, [0, 0])
        ws._data = {'A1': {'v': 11}, 'A2': {'v': 21}}
        ws._calc_size()
        self.assertEqual(ws.size, [2, 1])
github PydPiper / pylightxl / test / test_worksheet.py View on Github external
def test_update_index(self):
        ws = Worksheet({})
        ws.update_index(row=4, col=2, val=42)
        self.assertEqual(ws.size, [4, 2])
        self.assertEqual(ws.index(4, 2), 42)
        self.assertEqual(ws.address('B4'), 42)
        self.assertEqual(ws.row(4)[1], 42)
        self.assertEqual(ws.col(2)[3], 42)
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_address(self):
        ws = Worksheet({'A1': {'v': 1}})
        self.assertEqual(ws.address(address='A1'), 1)
        self.assertEqual(ws.address('A2'), '')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_index(self):
        ws = Worksheet({'A1': {'v': 1}})
        self.assertEqual(ws.index(row=1, col=1), 1)
        self.assertEqual(ws.index(1, 2), '')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_rows(self):
        ws = Worksheet({'A1': {'v': 11}, 'A2': {'v': 21}, 'B1': {'v': 12}})
        correct_list = [[11, 12], [21, '']]
        for i, row in enumerate(ws.rows):
            self.assertEqual(row, correct_list[i])
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_keycol(self):
        ws = Worksheet({'A1': {'v': 11}, 'B1': {'v': 11}, 'C1': {'v': 13},
                        'A2': {'v': 21}, 'B2': {'v': 22}, 'C2': {'v': 23},
                        'A3': {'v': 11}, 'B3': {'v': 32}, 'C3': {'v': 33}})
        self.assertEqual(ws.keycol(key=11),[11,21,11])
        self.assertEqual(ws.keycol(key=11,keyindex=1),[11,21,11])
        self.assertEqual(ws.keycol(key=11,keyindex=2),[])
        self.assertEqual(ws.keycol(key=32,keyindex=3),[11,22,32])

        self.assertEqual(ws.keyrow(key=11),[11,11,13])
        self.assertEqual(ws.keyrow(key=11,keyindex=1),[11,11,13])
        self.assertEqual(ws.keyrow(key=11,keyindex=2),[11,11,13])
        self.assertEqual(ws.keyrow(key=22,keyindex=2),[21,22,23])
        self.assertEqual(ws.keyrow(key=22,keyindex=3),[])
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_calc_size(self):
        ws = Worksheet({})
        # force calc size
        ws._calc_size()
        self.assertEqual(ws.maxrow, 0)
        self.assertEqual(ws.maxcol, 0)

        ws._data = {'A1': {'v': 11}}
        ws._calc_size()
        self.assertEqual(ws.maxrow, 1)
        self.assertEqual(ws.maxcol, 1)

        ws._data = {'A1': {'v': 11}, 'A2': {'v': 21}}
        ws._calc_size()
        self.assertEqual(ws.maxrow, 2)
        self.assertEqual(ws.maxcol, 1)

        ws._data = {'A1': {'v': 11}, 'A2': {'v': 21}, 'B1': {'v': 12}}
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_ws_row(self):
        ws = Worksheet({'A1': {'v': 11}, 'A2': {'v': 21}, 'B1': {'v': 12}})
        self.assertEqual(ws.row(row=1), [11, 12])
        self.assertEqual(ws.row(2), [21, ''])
        self.assertEqual(ws.row(3), ['', ''])
github PydPiper / pylightxl / pylightxl / database.py View on Github external
def add_ws(self, sheetname, data):
        """
        Logs worksheet name and its data in the database

        :param str sheetname: worksheet name
        :param data: dictionary of worksheet cell values (ex: {'A1': {'v':10,'f':'','s':''}, 'A2': {'v':20,'f':'','s':''}})
        :return: None
        """

        self._ws.update({sheetname: Worksheet(data)})
        self._ws_names.append(sheetname)