fcur.execute("select path from gar.adm_hierarchy where objectid in (select objectid from gar.addr_obj where objectguid=%s)",[fias_aoid])
yy = fcur.fetchone()
if yy is not None:
fcur.execute("select name from gar.addr_obj where objectid in (select split_part(%s,'.',1)::integer from gar.addr_obj) ",[yy])
zz = fcur.fetchone()
if zz is not None:
data_ws[f'L{data_counter}'].value = zz[0]
if yy.count('.') == 1:
fcur.execute("select name from gar.addr_obj where objectid in (select split_part(%s,'.',2)::integer from gar.addr_obj) ",[yy])
zz = fcur.fetchone()
if zz is not None:
data_ws[f'M{data_counter}'].value = zz[0]
if yy.count('.') == 2:
fcur.execute("select name,level from gar.addr_obj where objectid in (select split_part(%s,'.',3)::integer from gar.addr_obj) ",[yy])
zz = fcur.fetchone()
if zz is not None:
data_ws[f'N{data_counter}'].value = zz[0]
if yy.count('.')==3:
fcur.execute("select name from gar.addr_obj where objectid in (select split_part(%s,'.',4)::integer from gar.addr_obj) ",[yy])
zzz = fcur.fetchone()
if zzz is not None:
data_ws[f'O{data_counter}'].value = zzz[0]
data_counter=data_counter+1