Пример #1
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
w = Writer("example_series_filter.xls")
w.write_reader(reader)
w.close()
Пример #2
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
w = Writer("example_series_filter.xls")
w.write_reader(reader)
w.close()
Пример #3
0
def main(base_dir):
    # print all in json
    #
    # Column 1 Column 2 Column 3
    # 1        4        7
    # 2        5        8
    # 3        6        9
    reader = SeriesReader(os.path.join(base_dir,"example_series.ods"))
    data = to_dict(reader)
    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
    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]}
    
    # and you can write the filtered results
    # into a file
    w = Writer("example_series_filter.xls")
    w.write_reader(reader)
    w.close()