How to use the pyexcel.utils.to_array 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 / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
print(data)
    #[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
    
    # get a two dimensional array
    data = to_array(reader.rows())
    print(data)
    #[[1.0, 4.0, 7.0], [2.0, 5.0, 8.0], [3.0, 6.0, 9.0]]
    
    # get a two dimensional array in reverse
    # order
    data = to_array(reader.rrows())
    print(data)
    # [[3.0, 6.0, 9.0], [2.0, 5.0, 8.0], [1.0, 4.0, 7.0]]
    
    # get a two dimensional array but stack columns 
    data = to_array(reader.columns())
    print(data)
    # [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
    
    # get a two dimensional array but stack columns
    # in reverse order
    data = to_array(reader.rcolumns())
    print(data)
    #[[7.0, 8.0, 9.0], [4.0, 5.0, 6.0], [1.0, 2.0, 3.0]]
    
    # filter out odd rows and even columns
    reader.filter(OddRowFilter())
    reader.filter(EvenColumnFilter())
    data = to_dict(reader)
    print(data)
    # {u'Column 3': [8.0], u'Column 1': [2.0]}
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
#[[1.0, 4.0, 7.0], [2.0, 5.0, 8.0], [3.0, 6.0, 9.0]]
    
    # get a two dimensional array in reverse
    # order
    data = to_array(reader.rrows())
    print(data)
    # [[3.0, 6.0, 9.0], [2.0, 5.0, 8.0], [1.0, 4.0, 7.0]]
    
    # get a two dimensional array but stack columns 
    data = to_array(reader.columns())
    print(data)
    # [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
    
    # get a two dimensional array but stack columns
    # in reverse order
    data = to_array(reader.rcolumns())
    print(data)
    #[[7.0, 8.0, 9.0], [4.0, 5.0, 6.0], [1.0, 2.0, 3.0]]
    
    # filter out odd rows and even columns
    reader.filter(OddRowFilter())
    reader.filter(EvenColumnFilter())
    data = to_dict(reader)
    print(data)
    # {u'Column 3': [8.0], u'Column 1': [2.0]}
    
    # and you can write the filtered results
    # into a file
    reader.save_as("example_series_filter.xls")
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
print(json.dumps(data))
    # output:
    # {"Column 2": [4.0, 5.0, 6.0], "Column 3": [7.0, 8.0, 9.0], "Column 1": [1.0, 2.0, 3.0]}
    
    # get the column headers
    print(reader.colnames)
    # [u'Column 1', u'Column 2', u'Column 3']
    
    # get the content in one dimensional array
    data = to_array(reader.enumerate())
    print(data)
    # [1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0]
    
    # get the content in one dimensional array
    # in reverse order
    data = to_array(reader.reverse())
    print(data)
    
    # get the content in one dimensional array
    # but iterate it vertically 
    data = to_array(reader.vertical())
    print(data)
    # [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
    
    # get the content in one dimensional array
    # but iterate it vertically in revserse
    # order
    data = to_array(reader.rvertical())
    print(data)
    #[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
    
    # get a two dimensional array
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
print(reader.colnames)
    # [u'Column 1', u'Column 2', u'Column 3']
    
    # get the content in one dimensional array
    data = to_array(reader.enumerate())
    print(data)
    # [1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0]
    
    # get the content in one dimensional array
    # in reverse order
    data = to_array(reader.reverse())
    print(data)
    
    # get the content in one dimensional array
    # but iterate it vertically 
    data = to_array(reader.vertical())
    print(data)
    # [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
    
    # get the content in one dimensional array
    # but iterate it vertically in revserse
    # order
    data = to_array(reader.rvertical())
    print(data)
    #[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
    
    # get a two dimensional array
    data = to_array(reader.rows())
    print(data)
    #[[1.0, 4.0, 7.0], [2.0, 5.0, 8.0], [3.0, 6.0, 9.0]]
    
    # get a two dimensional array in reverse
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
# get the content in one dimensional array
    # but iterate it vertically 
    data = to_array(reader.vertical())
    print(data)
    # [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
    
    # get the content in one dimensional array
    # but iterate it vertically in revserse
    # order
    data = to_array(reader.rvertical())
    print(data)
    #[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
    
    # get a two dimensional array
    data = to_array(reader.rows())
    print(data)
    #[[1.0, 4.0, 7.0], [2.0, 5.0, 8.0], [3.0, 6.0, 9.0]]
    
    # get a two dimensional array in reverse
    # order
    data = to_array(reader.rrows())
    print(data)
    # [[3.0, 6.0, 9.0], [2.0, 5.0, 8.0], [1.0, 4.0, 7.0]]
    
    # get a two dimensional array but stack columns 
    data = to_array(reader.columns())
    print(data)
    # [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
    
    # get a two dimensional array but stack columns
    # in reverse order
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 / series.py View on Github external
# get the content in one dimensional array
    # in reverse order
    data = to_array(reader.reverse())
    print(data)
    
    # get the content in one dimensional array
    # but iterate it vertically 
    data = to_array(reader.vertical())
    print(data)
    # [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
    
    # get the content in one dimensional array
    # but iterate it vertically in revserse
    # order
    data = to_array(reader.rvertical())
    print(data)
    #[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
    
    # get a two dimensional array
    data = to_array(reader.rows())
    print(data)
    #[[1.0, 4.0, 7.0], [2.0, 5.0, 8.0], [3.0, 6.0, 9.0]]
    
    # get a two dimensional array in reverse
    # order
    data = to_array(reader.rrows())
    print(data)
    # [[3.0, 6.0, 9.0], [2.0, 5.0, 8.0], [1.0, 4.0, 7.0]]
    
    # get a two dimensional array but stack columns 
    data = to_array(reader.columns())