本文整理汇总了Python中pyexcel.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_row_in_file_filter
def test_row_in_file_filter(self):
r1 = pe.load("testcsv1.csv")
r2 = pe.load("testcsv2.csv")
r2.filter(pe.filters.ColumnFilter([2]))
r1.filter(pe.filters.RowInFileFilter(r2))
result = [1, 'a', 2, 'b', 3, 'c', 8, 'h']
actual = pe.utils.to_array(r1.enumerate())
self.assertEqual(result, actual)
示例2: test_row_value_filter
def test_row_value_filter(self):
r1 = pe.load("testcsv1.csv")
r2 = pe.load("testcsv2.csv")
filter_func = lambda array: r2.contains((lambda row: array[0] == row[0] and array[1] == row[1]))
r1.filter(pe.filters.RowValueFilter(filter_func).invert())
result = ['1', 'a', '2', 'b', '3', 'c', '8', 'h']
actual = pe.utils.to_array(r1.enumerate())
assert result == actual
示例3: test_row_in_file_filter
def test_row_in_file_filter(self):
r1 = pe.load("testcsv1.csv")
r2 = pe.load("testcsv2.csv")
r2.filter(pe.filters.ColumnFilter([2]))
r1.filter(pe.filters.RowInFileFilter(r2))
result = ['1', 'a', '2', 'b', '3', 'c', '8', 'h']
actual = pe.utils.to_array(r1.enumerate())
assert result == actual
示例4: test_row_value_filter
def test_row_value_filter(self):
r1 = pe.load("testcsv1.csv")
r2 = pe.load("testcsv2.csv")
def filter_func(array):
def func(row): return array[0] == row[0] and array[1] == row[1]
return r2.contains(func)
r1.filter(pe.filters.RowValueFilter(filter_func).invert())
result = [1, 'a', 2, 'b', 3, 'c', 8, 'h']
actual = pe.utils.to_array(r1.enumerate())
self.assertEqual(result, actual)
示例5: test_pyexcel_issue_5
def test_pyexcel_issue_5(self):
"""pyexcel issue #5
datetime is not properly parsed
"""
s = pe.load(os.path.join("tests",
"test-fixtures",
"test-date-format.xls"))
s.save_as("issue5.xlsx")
s2 = pe.load("issue5.xlsx")
print(s[0,0])
assert s[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
assert s2[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
示例6: test_pyexcel_issue_5
def test_pyexcel_issue_5():
"""pyexcel issue #5
datetime is not properly parsed
"""
s = pe.load(get_fixture("test-date-format.xls"))
assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
示例7: test_pyexcel_issue_8_with_memory_file
def test_pyexcel_issue_8_with_memory_file(self):
"""pyexcel issue #8
formular got lost
"""
tmp_file = "issue_8_save_as.xlsx"
f = open(os.path.join("tests",
"test-fixtures",
"test8.xlsx"),
"rb")
s = pe.load_from_memory('xlsx', f.read())
s.save_as(tmp_file)
s2 = pe.load(tmp_file)
assert str(s) == str(s2)
content = dedent("""
Sheet Name: CNY
+----------+----------+------+---+--------+
| 01/09/13 | 02/09/13 | 1000 | 5 | 13.890 |
+----------+----------+------+---+--------+
| 02/09/13 | 03/09/13 | 2000 | 6 | 33.330 |
+----------+----------+------+---+--------+
| 03/09/13 | 04/09/13 | 3000 | 7 | 58.330 |
+----------+----------+------+---+--------+""").strip("\n")
assert str(s2) == content
os.unlink(tmp_file)
示例8: test_even_row_filter
def test_even_row_filter(self):
r = pe.load(self.test_tuple)
r.filter(pe.filters.EvenRowFilter())
assert r.number_of_rows() == 2
assert r.number_of_columns() == 4
result = [1, 2, 3, 4, 9, 10, 11, 12]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例9: test_write_and_read
def test_write_and_read(self):
data = [[11, 112], [312, 534]]
sheet = pe.Sheet(data)
sheet.save_as(self.testfile)
sheet2 = pe.load(self.testfile)
sheet2.format(int)
result = sheet2.to_array()
assert data == result
示例10: test_column_filter_with_invalid_indices
def test_column_filter_with_invalid_indices(self):
r = pe.load((self.file_type, self.testfile.getvalue()))
r.filter(pe.filters.ColumnFilter([11, -1]))
assert r.number_of_rows() == 3
assert r.number_of_columns() == 4
result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例11: test_row_filter_with_invalid_indices
def test_row_filter_with_invalid_indices(self):
r = pe.load(self.test_tuple)
r.filter(pe.filters.RowFilter([11, -1]))
assert r.number_of_rows() == 3
assert r.number_of_columns() == 4
result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例12: test_single_row_filter
def test_single_row_filter(self):
r = pe.load((self.file_type, self.testfile.getvalue()))
r.filter(pe.filters.SingleRowFilter(1))
assert r.number_of_rows() == 2
assert r.number_of_columns() == 4
result = [1, 2, 3, 4, 9, 10, 11, 12]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例13: test_odd_row_filter
def test_odd_row_filter(self):
r = pe.load(self.test_tuple)
r.filter(pe.filters.OddRowFilter())
assert r.number_of_rows() == 1
assert r.number_of_columns() == 4
result = [5, 6, 7, 8]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例14: test_even_column_filter
def test_even_column_filter(self):
r = pe.load(self.test_tuple)
r.filter(pe.filters.EvenColumnFilter())
assert r.number_of_rows() == 3
assert r.number_of_columns() == 2
result = [1, 3, 5, 7, 9, 11]
actual = pe.utils.to_array(r.enumerate())
assert result == actual
示例15: test_odd_column_filter
def test_odd_column_filter(self):
r = pe.load(self.test_tuple)
r.filter(pe.filters.OddColumnFilter())
assert r.number_of_rows() == 3
assert r.number_of_columns() == 2
result = [2, 4, 6, 8, 10, 12]
actual = pe.utils.to_array(r.enumerate())
assert result == actual