-
Notifications
You must be signed in to change notification settings - Fork 42
/
05_03_le_meta_dados.py
50 lines (36 loc) · 1.17 KB
/
05_03_le_meta_dados.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
def extract_name(name):
return name.split(".")[0]
def read_lines(filename):
_file = open(os.path.join("data/meta-data", filename), "rt")
data = _file.read().split("\n")
_file.close()
return data
def read_metadata(filename):
metadata = []
for column in read_lines(filename):
if column:
values = column.split('\t')
nome = values[0]
tipo = values[1]
desc = values[2]
metadata.append((nome, tipo, desc))
return metadata
def main():
# dicionario nome entidade -> atributos
meta = {}
# dicionario identificador -> nome entidade
keys = {}
for meta_data_file in os.listdir("data/meta-data"):
table_name = extract_name(meta_data_file)
attributes = read_metadata(meta_data_file)
identifier = attributes[0][0]
meta[table_name] = attributes
keys[identifier] = table_name
for key, val in meta.items():
for col in val:
if col[0] in keys:
if not col[0] == meta[key][0][0]:
print("Entiade {} aponta para {}".format(key, col[0]))
if __name__ == "__main__":
main()