Skip to content

Commit

Permalink
999999999_521850.py (#43): hxltm__data_pivot_wide() started
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Aug 3, 2022
1 parent 3da0784 commit fceb3a7
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 1 deletion.
6 changes: 5 additions & 1 deletion officina/999999999/0/999999999_521850.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from L999999999_0 import (
# hxltm_carricato,
NUMERORDINATIO_BASIM,
hxltm__data_pivot_wide,
hxltm__data_sort,
numerordinatio_neo_separatum,
# TabulaAdHXLTM
Expand Down Expand Up @@ -1155,9 +1156,12 @@ def de_hxltm_ad_hxltm_wide(
data_sorted = hxltm__data_sort(
fonti, ['#item+rem+i_qcc+is_zxxx+ix_xyadhxltrivio'])

caput, data = hxltm__data_pivot_wide(data_sorted[0], data_sorted[1:])

# print(data_sorted[0:10])
print(caput, data[0:10])

# raise NotImplementedError
raise NotImplementedError

with open(objetivum, 'w') as _objetivum:
# with open(fonti, 'r') as _fons:
Expand Down
115 changes: 115 additions & 0 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5445,6 +5445,121 @@ def hxltm__data_sort(fonti: str, sortkeys: list = None) -> list:
return resultatum


def hxltm__data_pivot_wide(caput: list, data: list) -> list:

referens_columnae = '#item+rem+i_qcc+is_zxxx+ix_xyadhxltrivio'

# No + as prefix here
hxlatt_ex = 'ix_xyexhxltrivio'
if referens_columnae not in caput:
raise SyntaxError('[{}] must exist on header <{}>'.format(
referens_columnae, caput))

referens_per_indici = caput.index(referens_columnae)
referens_ad_indici = []
for item in caput:
if hxlatt_ex in item:
referens_ad_indici.append(caput.index(item))
if len(referens_ad_indici) == 0:
raise SyntaxError('{} not in header <{}>'.format(hxlatt_ex, caput))

referens_hxlattrs = []
for linea in data:
if linea[referens_per_indici] not in referens_hxlattrs:
referens_hxlattrs.append(linea[referens_per_indici])

sorted(referens_hxlattrs)

columna_novae__list = []
columna_novae__mapping = {}

for item_I in referens_hxlattrs:
for item_II in referens_ad_indici:

res = hxl_hashtag_normalizatio(
caput[item_II].replace(hxlatt_ex, item_I))
if res in columna_novae__list:
continue
columna_novae__list.append(res)
# columna_novae__mapping[item_I] = columna_novae__list.index(res)
columna_novae__mapping[item_I] = len(columna_novae__list) - 1
# pass
# columna_novae__list

data_novae__dict = {}
_codice_indici = caput.index('#item+conceptum+codicem')
for linea in data:
_codicem = linea[_codice_indici]
_referens = linea[referens_per_indici]
__start = columna_novae__mapping[_referens]
__diff = len(columna_novae__list)
if _codicem not in data_novae__dict:
data_novae__dict[_codicem] = {
'originalis': linea,
# 'data_novae': [''] * len(columna_novae__list),
'data_novae': [''] * (len(columna_novae__list) + 1),
}

__loop = 0
# print(len(data_novae__dict[_codicem]['data_novae']))
for index_originalis in referens_ad_indici:
# index_novae = __start + index_originalis
# print(__loop, len(data_novae__dict[_codicem]['data_novae']))
index_novae = __start + __loop
if index_novae not in data_novae__dict[_codicem]['data_novae']:
print('error', index_novae, len(data_novae__dict[_codicem]['data_novae']))
continue
data_novae__dict[_codicem]['data_novae'][index_novae] = \
linea[index_originalis]
__loop += 1

# for item in caput:
# for item_II in referens_ad_indici:

# pass

raise NotImplementedError(data_novae__dict['4'])
raise NotImplementedError(columna_novae__list, columna_novae__mapping)

# if not sortkeys:
# sortkeys = []

# if '#item+conceptum+codicem' not in sortkeys:
# sortkeys.insert(0, '#item+conceptum+codicem')

# _data = []
# caput = []
# with open(fonti, 'r') as _fons:
# _csv_reader = csv.reader(_fons)
# # started = False
# for linea in _csv_reader:
# if len(caput) == 0:
# caput = linea
# continue
# _data.append(linea)

# _i0 = caput.index(sortkeys[0])
# if len(sortkeys) == 1:
# _data = sorted(_data, key=lambda row: int(row[_i0]))
# elif len(sortkeys) == 2:
# _i1 = caput.index(sortkeys[1])
# _data = sorted(_data, key=lambda row: (int(row[_i0]), row[_i1]))
# elif len(sortkeys) == 3:
# _i1 = caput.index(sortkeys[1])
# _i2 = caput.index(sortkeys[2])
# _data = sorted(
# _data, key=lambda row: (int(row[_i0]), row[_i1], row[_i2]))
# else:
# raise NotImplementedError('len > 3; [{}] <{}>'.format(
# len(sortkeys), sortkeys))

# resultatum = []
# resultatum.append(caput)
# resultatum.extend(_data)

return caput, data


def hxltm__concat(
# al1: str, b2: str,
significatus: dict,
Expand Down

0 comments on commit fceb3a7

Please sign in to comment.