How to use the pyexcel.Reader 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_io_csvbook.py View on Github external
def test_write_utf_and_read_back(self):
        data = [
            [u'白', u'日', u'依', u'山', u'尽'],
            [u'黄', u'河', u'入', u'海', u'流'],
            [u'欲', u'穷', u'千', u'里', u'目'],
            [u'更', u'上', u'一', u'层', u'楼']
        ]
        w = pyexcel.Writer("utf.csv")
        w.write_rows(data)
        w.close()
        r = pyexcel.Reader("utf.csv")
        expected = pyexcel.utils.to_array(r)
        print(expected)
        print(data)
        assert expected == data
github pyexcel / pyexcel / tests / base.py View on Github external
def test_slice(self):
        r = pe.Reader(self.testfile)
        content1 = [[1, 1, 1, 1]]
        assert content1 == r.row[0:1]
        content2 = [[1, 1, 1, 1], [2, 2, 2, 2]]
        assert content2 == r.row[0:2]
        assert content2 == r.row[:2]
        content3 = [[2, 2, 2, 2], [3, 3, 3, 3]]
        assert content3 == r.row[1:]
        content4 = [[1, 1, 1, 1], [2, 2, 2, 2]]
        assert content4 == r.row[0:2:1]
        content5 = [1, 1, 1, 1]
        assert [content5] == r.row[0:0]
        r.row[2:1]  # bang
github pyexcel / pyexcel / tests / test_reader.py View on Github external
def test_contains(self):
        r = p.Reader(self.testfile)

        def f(row):
            return row[0] == "a" and row[1] == "b"

        assert r.contains(f) is True
github pyexcel / pyexcel / tests / test_reader.py View on Github external
def test_column_at(self):
        r = p.Reader(self.testfile)
        value = r.column_at(1)
        assert value == ["b", "f", "j"]
        value = r.column_at(100)  # bang
github pyexcel / pyexcel / examples / simple_usage / flatteni.py View on Github external
import pyexcel

# "example.csv","example.xlsx","example.ods", "example.xlsm"
spreadsheet = pyexcel.Reader("example.xls") 

for value in spreadsheet:
    print value
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / formatting / formatter02.py View on Github external
def main(base_dir):
    r=Reader(os.path.join(base_dir, "tutorial_datatype_02.ods"))
    to_array(r)
    
    def cleanse_func(v):
        v = v.replace(" ", "")
        v = v.rstrip().strip()
        return v
    
    sf = SheetFormatter(cleanse_func)
    r.add_formatter(sf)
    to_array(r)
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / read_column_by_column.py View on Github external
def main(base_dir):
    # "example.csv","example.ods","example.xls", "example.xlsm"
    spreadsheet = pyexcel.Reader(os.path.join(base_dir, "example.xlsx"))
    
    # columns() returns column based iterator, meaning it can be iterated
    # column by column 
    for value in spreadsheet.columns():
        print(value)
github pyexcel / pyexcel / examples / simple_usage / flatten_row_by_row.py View on Github external
import pyexcel

# "example.csv","example.xlsx","example.xls", "example.xlsm"
spreadsheet = pyexcel.Reader("example.ods") 

for value in spreadsheet.rows():
    print value
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / read_cell_by_cell.py View on Github external
def main(base_dir):
    # Simple give the file name to **Reader**
    # "example.xls","example.xlsx","example.ods", "example.xlsm"
    spreadsheet = pyexcel.Reader(os.path.join(base_dir, "example.csv"))
    
    # row_range() gives [0 .. number of rows]
    for r in spreadsheet.row_range():
        # column_range() gives [0 .. number of ranges]
        for c in spreadsheet.column_range():
            # cell_value(row_index, column_index)
            # return the value at the specified
            # position
            # please note that both row_index
            # and column_index starts from 0
            print(spreadsheet.cell_value(r, c))