-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy_and_rename.py
39 lines (36 loc) · 1.1 KB
/
copy_and_rename.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
"""With the multilingual_speech_valence_classification_datasets downloaded, this script renames each file listed in aggregate_data_files.tsv and copies them to data/interim/."""
from shutil import copyfile
prefix_path = "data/multilingual_speech_valence_classification_datasets/datasets/"
in_file = "aggregate_data_files.tsv"
with open(f"{prefix_path}{in_file}", "r") as f:
count = 0
for record in f.readlines():
(
path,
emo,
valence,
lang1,
lang2,
speaker,
gender,
dataset,
) = record.strip().split("\t")
new_file = "+".join(
_.replace("+", ".").replace("/", ")")
for _ in (
f"{count:05}",
dataset,
speaker,
gender,
emo,
valence,
lang1,
lang2,
)
)
copyfile(
f"{prefix_path}{path}",
f"data/interim/{new_file}.{path.rsplit('.', maxsplit=1)[-1]}",
)
count += 1
print("done")