Skip to content

Commit

Permalink
999999999_0.py (#42): cached index already able to be created at 9999…
Browse files Browse the repository at this point in the history
…99/0/{1}.index.json
  • Loading branch information
fititnt committed May 21, 2022
1 parent 3698363 commit 911e501
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 17 deletions.
28 changes: 24 additions & 4 deletions officinam/999999999/0/999999999_7200235.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
--ex-selectis='#item+conceptum+codicem==1'
Index preparation (warn up cache) . . . . . . . . . . . . . . . . . . . . . . .
(this will pre-create a key-value index at 999999/0/i1603_45_49.index.json)
{0} --methodus=index_praeparationi 1603_45_49 \
--index-nomini=i1603_45_49 \
--ex-columnis='#item+rem+i_zxx+is_zmth+ix_unm49,\
Expand Down Expand Up @@ -532,10 +533,29 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,

if pyargs.methodus == 'index_praeparationi':

caput, data = hxltm_index_praeparationi(caput, data)
# ex_columnis = pyargs.ex_columnis.split(',')
# caput, data = hxltm_ex_columnis(caput, data, ex_columnis)
print('TODO')
if pyargs.index_nomini:
index_nomini = pyargs.index_nomini
else:
# In this case, _infile is just a string like 1603_45_49
index_nomini = 'i{0}'.format(str(_infile))

data_json = hxltm_index_praeparationi(
caput, data, pyargs.index_ad_columnam)

data_json_str = json.dumps(
data_json, indent=4, sort_keys=False, ensure_ascii=False)

# print(data_json_str)

_path = '{0}/999999/0/{1}.index.json'.format(
NUMERORDINATIO_BASIM,
index_nomini,
)

with open(_path, "w") as file1:
file1.write(data_json_str)
print('index: {0}'.format(_path))
return self.EXIT_OK

csv_imprimendo(caput, data)

Expand Down
58 changes: 45 additions & 13 deletions officinam/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,9 @@ def hxltm_ex_selectis(


def hxltm_index_praeparationi(
caput: list, data: list, index_ad_columnam: str) -> dict:
caput: list, data: list,
index_ad_columnam: str = None, strictum: bool = False
) -> dict:
"""hxltm_index_praeparationi add new columns (variables)
Trivia:
Expand All @@ -1755,25 +1757,55 @@ def hxltm_index_praeparationi(
caput (list): _description_
data (list): _description_
index_ad_columnam (str): _description_
strictum (str): raise errors if same source keys can point to different
objective indexes.
Returns:
dict: _description_
"""
# https://en.wiktionary.org/wiki/columna#Latin
index_columnae = []
_data = []
raise NotImplementedError
# print(caput, columnae)
for item in columnae:
index_columnae.append(caput.index(item))

if strictum:
raise NotImplementedError('{0} strictum'.format(
'hxltm_index_praeparationi'))

if not index_ad_columnam:
index_ad_columnam = 0
else:
index_ad_columnam = caput.index(index_ad_columnam)

_data_json = {}
data_json = {}

for linea in data:
_linea = []
for index in index_columnae:
_linea.append(linea[index])
_data.append(_linea)
_clavis_ad = linea[index_ad_columnam]
_clavis_ex = set()
for res in linea:
if res:
_clavis_ex.add(res)
for item in _clavis_ex:
_data_json[item] = _clavis_ad

_claves_n = []
_claves_l = []
_clāvēs_nl = []

for item in _data_json.keys():
if item.isnumeric():
_claves_n.append(item)
else:
_claves_l.append(item)

# _caput = columnae
if len(_claves_n) > 0:
_clāvēs_nl.extend(sorted(_claves_n, key=lambda x: int(x)))

if len(_claves_l) > 0:
_claves_l.sort(key=lambda item: (len(item), item))
_clāvēs_nl.extend(_claves_l)

for item in _clāvēs_nl:
data_json[item] = _data_json[item]

return data_json


def hxltm_per_columnas(
Expand Down

0 comments on commit 911e501

Please sign in to comment.