Skip to content
Snippets Groups Projects
Commit 44df1b4b authored by David Verelst's avatar David Verelst
Browse files

sort by Excel file name when constructing DLC opt_tags,

revert commit 0340b1b5
parent 2705feb7
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -240,8 +240,8 @@ def tags_defaults(master): ...@@ -240,8 +240,8 @@ def tags_defaults(master):
return master return master
def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0, def excel_stabcon(proot, fext='xlsx', pignore=None, pinclude=None, sheet=0,
pinclude=None, silent=False): silent=False):
""" """
Read all MS Excel files that hold load case definitions according to Read all MS Excel files that hold load case definitions according to
the team STABCON definitions. Save each case in a list according to the the team STABCON definitions. Save each case in a list according to the
...@@ -251,6 +251,9 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0, ...@@ -251,6 +251,9 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0,
are added to be compatible with the tag convention in the Simulations are added to be compatible with the tag convention in the Simulations
module. module.
The opt_tags case list is sorted according to the Excel file names, and
follows the same ordering as in each of the different Excel files.
Parameters Parameters
---------- ----------
...@@ -272,25 +275,32 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0, ...@@ -272,25 +275,32 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0,
Name or index of the Excel sheet to be considered. By default, the Name or index of the Excel sheet to be considered. By default, the
first sheet (index=0) is taken. first sheet (index=0) is taken.
Returns
-------
opt_tags : list of dicts
A list of case dictionaries, where each case dictionary holds all
the tag/value key pairs for a single given case.
""" """
if not silent: if not silent:
print('looking for DLC spreadsheet definitions at:') print('looking for DLC spreadsheet definitions at:')
print(proot) print(proot)
df_list = misc.read_excel_files(proot, fext=fext, pignore=pignore, dict_dfs = misc.read_excel_files(proot, fext=fext, pignore=pignore,
sheet=sheet, pinclude=pinclude, sheet=sheet, pinclude=pinclude,
silent=silent) silent=silent)
if not silent: if not silent:
print('found %i Excel file(s), ' % len(df_list), end='') print('found %i Excel file(s), ' % len(dict_dfs), end='')
k = 0 k = 0
for df in df_list: for df in dict_dfs:
k += len(df) k += len(df)
if not silent: if not silent:
print('in which a total of %s cases are defined.' % k) print('in which a total of %s cases are defined.' % k)
opt_tags = [] opt_tags = []
for (dlc, df) in viewitems(df_list): for (dlc, df) in sorted(viewitems(dict_dfs)):
# replace ';' with False, and Nan(='') with True # replace ';' with False, and Nan(='') with True
# this is more easy when testing for the presence of stuff compared # this is more easy when testing for the presence of stuff compared
# to checking if a value is either True/False or ''/';' # to checking if a value is either True/False or ''/';'
......
...@@ -716,17 +716,16 @@ def read_excel_files(proot, fext='xlsx', pignore=None, sheet=0, ...@@ -716,17 +716,16 @@ def read_excel_files(proot, fext='xlsx', pignore=None, sheet=0,
Returns Returns
------- -------
df_list : list df_list : dictionary
A list of pandas DataFrames. Each DataFrame corresponds to the A dictionary with the Excel file name (excluding 'fext') as key, and
contents of a single Excel file that was found in proot or one of the corresponding pandas DataFrame as value.
its sub-directories
""" """
df_list = {} df_list = {}
# find all dlc defintions in the subfolders # find all dlc defintions in the subfolders
for root, dirs, files in os.walk(proot): for root, dirs, files in os.walk(proot):
for file_name in sorted(files): for file_name in files:
if not file_name.split('.')[-1] == fext: if not file_name.split('.')[-1] == fext:
continue continue
f_target = os.path.join(root, file_name) f_target = os.path.join(root, file_name)
......
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