-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexMng.py
49 lines (41 loc) · 897 Bytes
/
IndexMng.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
"""
platform: any
env: any
name: IndexMng.py
Manage dataset index
"""
from config import *
import os
def get_index_from_dir(d):
"""
get index from directory
:param d: directory
:return: index list
"""
ids = []
files = os.listdir(d)
for f in files:
if len(f) == 4:
ids.append(f)
return ids
def get_index_from_file(index_dot_txt):
"""
get index from index file
:param index_dot_txt: index file
:return: index list
"""
ids = []
with open(index_dot_txt, 'r') as f:
for line in f.readlines():
ids.append(line[0:4])
return ids
def test():
"""
test
:return:
"""
# print(len(get_index_from_dir(ecif_2019_general_minus_refined)))
ign_test = os.path.join(ign_index_dir, "test.index.txt")
print(get_index_from_file(ign_test))
if __name__ == '__main__':
test()