search in horizontale
This commit is contained in:
parent
cf41711716
commit
fd706d59ba
Binary file not shown.
|
@ -32,29 +32,32 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
|
||||||
|
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
# ~ print('Columns', lookup_array.Columns.Count)
|
|
||||||
# ~ print('Rows', lookup_array.Rows.Count)
|
|
||||||
|
|
||||||
source = lookup_array.DataArray
|
source = lookup_array.DataArray
|
||||||
target = return_array.DataArray
|
target = return_array.DataArray
|
||||||
|
|
||||||
if search_mode == 1:
|
horizontal = False
|
||||||
index = next((i for i, v in enumerate(source) if v[0] == lookup_value), None)
|
if lookup_array.Columns.Count == 1:
|
||||||
elif search_mode == -1:
|
source = tuple(map(lambda x: x[0], source))
|
||||||
index = next((i for i, v in enumerate(reversed(source)) if v[0] == lookup_value), None)
|
else:
|
||||||
|
horizontal = True
|
||||||
|
source = source[0]
|
||||||
|
target = target[0]
|
||||||
|
|
||||||
|
if search_mode == -1:
|
||||||
|
source = tuple(reversed(source))
|
||||||
|
|
||||||
|
index = next((i for i, v in enumerate(source) if v == lookup_value), None)
|
||||||
|
|
||||||
if index is None:
|
if index is None:
|
||||||
if match_mode in (-1, 1, 2):
|
|
||||||
source = map(lambda x: x[0], source))
|
|
||||||
if search_mode == -1:
|
|
||||||
source = reversed(source)
|
|
||||||
source = tuple(source)
|
|
||||||
if match_mode == -1:
|
if match_mode == -1:
|
||||||
index = bisect.bisect_right(source, lookup_value)
|
index = bisect.bisect_right(source, lookup_value)
|
||||||
value = (target[index - 1],)
|
value = (target[index - 1],)
|
||||||
elif match_mode == 1:
|
elif match_mode == 1:
|
||||||
index = bisect.bisect_left(source, lookup_value)
|
index = bisect.bisect_left(source, lookup_value)
|
||||||
value = (target[index],)
|
value = (target[index],)
|
||||||
|
else:
|
||||||
|
if horizontal:
|
||||||
|
value = ((target[index],),)
|
||||||
else:
|
else:
|
||||||
value = (target[index],)
|
value = (target[index],)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue