implementation of pyexcel-io v0.2.2 paginantion support. the answer to big size csv

This commit is contained in:
chfw 2016-08-22 08:41:27 +01:00
parent 465d28c7e0
commit 2be6871ddf
3 changed files with 73 additions and 1 deletions

View File

@ -104,7 +104,16 @@ class XLSheet(SheetReader):
for row in range(0, self.number_of_rows()):
return_row = []
tmp_row = []
if self.skip_row(row, self.start_row, self.row_limit):
continue
for column in range(0, self.number_of_columns()):
skip_column = self.skip_column(column,
self.start_column,
self.column_limit)
if skip_column:
continue
cell_value = self.cell_value(row, column)
tmp_row.append(cell_value)
if cell_value is not None and cell_value != '':

View File

@ -107,7 +107,7 @@ class PyexcelMultipleSheetBase:
for s in b:
data = pyexcel.utils.to_array(s)
assert self.content[s.name] == data
si = pyexcel.iterators.SheetIterator(b)
si = pyexcel.sheets.iterators.SheetIterator(b)
for s in si:
data = pyexcel.utils.to_array(s)
assert self.content[s.name] == data

63
tests/test_filter.py Normal file
View File

@ -0,0 +1,63 @@
import os
from pyexcel_io import get_data, save_data
from nose.tools import eq_
class TestFilter:
def setUp(self):
self.test_file = "test_filter.xlsx"
sample = [
[1, 21, 31],
[2, 22, 32],
[3, 23, 33],
[4, 24, 34],
[5, 25, 35],
[6, 26, 36]
]
save_data(self.test_file, sample)
self.sheet_name = "pyexcel_sheet1"
def test_filter_row(self):
filtered_data = get_data(self.test_file, start_row=3,
library="pyexcel-xls")
expected = [[4, 24, 34], [5, 25, 35], [6, 26, 36]]
eq_(filtered_data[self.sheet_name], expected)
def test_filter_row_2(self):
filtered_data = get_data(self.test_file, start_row=3, row_limit=1,
library="pyexcel-xls")
expected = [[4, 24, 34]]
eq_(filtered_data[self.sheet_name], expected)
def test_filter_column(self):
filtered_data = get_data(self.test_file, start_column=1,
library="pyexcel-xls")
expected = [[21, 31], [22, 32], [23, 33],
[24, 34], [25, 35], [26, 36]]
eq_(filtered_data[self.sheet_name], expected)
def test_filter_column_2(self):
filtered_data = get_data(self.test_file,
start_column=1, column_limit=1,
library="pyexcel-xls")
expected = [[21], [22], [23], [24], [25], [26]]
eq_(filtered_data[self.sheet_name], expected)
def test_filter_both_ways(self):
filtered_data = get_data(self.test_file,
start_column=1, start_row=3,
library="pyexcel-xls")
expected = [[24, 34], [25, 35], [26, 36]]
eq_(filtered_data[self.sheet_name], expected)
def test_filter_both_ways_2(self):
filtered_data = get_data(self.test_file,
start_column=1, column_limit=1,
start_row=3, row_limit=1,
library="pyexcel-xls")
expected = [[24]]
eq_(filtered_data[self.sheet_name], expected)
def tearDown(self):
os.unlink(self.test_file)