Skip to content
Snippets Groups Projects
Commit d49a5f5c authored by Recolic Keghart's avatar Recolic Keghart
Browse files

bug fix

parent 0e86c23d
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,11 @@ def trim_npArr(np_bi_arr): ...@@ -48,7 +48,11 @@ def trim_npArr(np_bi_arr):
res.append(_trim_str(line)) res.append(_trim_str(line))
else: else:
res.append([_trim_str(item) for item in line]) res.append([_trim_str(item) for item in line])
return np.array(res) if len(res) == 0 or type(res[0]) != list:
return np.array([res])
else:
return np.array(res)
import pandas import pandas
......
...@@ -151,19 +151,22 @@ def add_product(serial, _id, name, quantity, must_have_xlsx=False, allow_recursi ...@@ -151,19 +151,22 @@ def add_product(serial, _id, name, quantity, must_have_xlsx=False, allow_recursi
contMat = _new_contMat contMat = _new_contMat
############ dirty end ############ dirty end
csv_preprocess.npmat2csv(contMat, csv_buf) # moved down # csv_preprocess.npmat2csv(contMat, csv_buf)
# recursive part reference for line in contMat:
if allow_recursive_part_ref: # recursive part reference
for line in contMat: if allow_recursive_part_ref:
line = line.tolist()[0] line_ar = line.tolist()[0]
part_name = line[config.part_name_col_index] part_name = line_ar[config.part_name_col_index]
part_id = get_id_prefix_from_string(part_name) part_id = get_id_prefix_from_string(part_name)
if part_id != '': if part_id != '':
if part_id.startswith(_id): if part_id.startswith(_id):
log_warn('Self-reference detected on part {}. Skipping recursive walking.'.format(_id)) log_warn('Self-reference detected on part {}. Skipping recursive walking.'.format(_id))
else: else:
add_product(serial, part_id, part_name, stoi(quantity)*stoi(line[config.part_quantity_col_index]), allow_recursive_part_ref=config.allow_part_tree_reference) add_product(serial, part_id, part_name, stoi(quantity)*stoi(line_ar[config.part_quantity_col_index]), allow_recursive_part_ref=config.allow_part_tree_reference)
continue # DO not put the parent material into csv_buf again!
# put line into csv_buf
csv_preprocess.npmat2csv(line, csv_buf)
else: else:
if must_have_xlsx: if must_have_xlsx:
name_and_id = '{}({})'.format(name, _id) name_and_id = '{}({})'.format(name, _id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment