self
._path
=
path
file_names
=
[os.path.join(root,
file
)
for
root, dirs, files
in
os.walk(
self
._path)
for
file
in
files
if
os.path.splitext(
file
)[
1
]
=
=
".txt"
]
for
file_path
in
file_names:
file_name
=
file_path.replace(
self
._path, '
').replace('
\\
', '
_')
var_value
=
os.path.splitext(file_name)[
0
]
var_key
=
'self.'
+
os.path.splitext(file_name)[
0
]
+
'_list'
var_dict
=
'self.'
+
os.path.splitext(file_name)[
0
]
+
'_dict'
exec
(f
'{var_value}=[]'
)
exec
(f
'{var_key}=[]'
)
exec
(f
'{var_dict}={{}}'
)
with
open
(file_path,
'r'
, encoding
=
'utf-8'
) as f:
txt_content
=
f.read()
exec
(f
"{var_value} = txt_content.split('\\n\\n')"
)
for
item
in
eval
(var_value):
if
item !
=
'':
key_mes
=
item.split(
'\t'
)
index_mes
=
key_mes[
0
]
exec
(f
"{var_key}.append(index_mes)"
)
exec
(f
"{var_dict} = dict(zip(eval(var_key), eval(var_value)))"
)