-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data_union.py
47 lines (32 loc) · 1.31 KB
/
Data_union.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
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 8 11:24:18 2018
@author: ich
Union of two precessed datasets
"""
import os
import shutil
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
msg = "Insert absolute path of the final database:"
final_data_path = input(msg)
msg = "Insert absolute path of the additional database:"
orig_data_path = input(msg)
gestures = os.listdir(orig_data_path)
for i in range(len(gestures)):
orig_gest_path = os.path.join(orig_data_path, gestures[i])
final_gest_path = os.path.join(final_data_path, gestures[i])
orig_repetitions = len(os.listdir(final_gest_path)) # Original number of repetitions
extra_repetitions = len(os.listdir(orig_gest_path)) # Extra number of repetitions
for j in range(extra_repetitions):
dir_orig = os.path.join(orig_gest_path, "rep_"+str(j).zfill(3))
dir_final = os.path.join(final_gest_path, "rep_"+str(orig_repetitions+j).zfill(3))
if not os.path.exists(dir_final):
os.mkdir(dir_final)
copytree(dir_orig, dir_final)