forked from felipecruz/exemplos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_01_le_meta_dados.py
41 lines (30 loc) · 958 Bytes
/
05_01_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
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():
meta = {}
for meta_data_file in os.listdir("data/meta-data"):
table_name = extract_name(meta_data_file)
meta[table_name] = read_metadata(meta_data_file)
for key, val in meta.items():
print("Tabela {}".format(key))
print(" Attributes: ")
for col in val:
print(" {}: {} - {}".format(col[1], col[0], col[2]))
if __name__ == "__main__":
main()