def parse_excel_file(input_file_name, input_file):
"""
Reads cycle's data and simulation plans.
:param input_file_name:
Input file name.
:type input_file_name: str
:param input_file:
Input file.
:type input_file: io.BytesIO
:return:
Raw input data.
:rtype: dict
"""
import pandas as pd
# noinspection PyProtectedMember
from pandalone.xleash.io._xlrd import _open_sheet_by_name_or_index
xl_file, res, plans = pd.ExcelFile(input_file), {'base': {}}, []
for sheet_name in xl_file.sheet_names:
match = _re_input_sheet_name.match(sheet_name.strip(' '))
if not match:
log.debug("Sheet name '%s' cannot be parsed!", sheet_name)
continue
match = {k: v.lower() for k, v in match.groupdict().items() if v}
# noinspection PyProtectedMember
sheet = _open_sheet_by_name_or_index(xl_file.book, 'book', sheet_name)
is_plan = match.get('scope', None) == 'plan'
if is_plan:
r = {'plan': pd.DataFrame()}
else:
r = {}
r = _parse_sheet(match, sheet, sheet_name, res=r)
if is_plan:
plans.append(r['plan'])
else:
_add_times_base(r, **match)
sh.combine_nested_dicts(r, depth=5, base=res)
for k, v in sh.stack_nested_keys(res['base'], depth=3):
if k[0] != 'target':
v['cycle_type'] = v.get('cycle_type', k[-1].split('_')[0]).upper()
v['cycle_name'] = v.get('cycle_name', k[-1]).upper()
res['plan'] = _finalize_plan(res, plans, input_file_name).to_dict('records')
return res