-
Notifications
You must be signed in to change notification settings - Fork 150
/
extract_data.py
32 lines (23 loc) · 1.03 KB
/
extract_data.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
import os
import sys
import subprocess
import numpy as np
import glob
import json
import pandas as pd
'''
This script creates a folder "Extracted_data" inside which it extracts all the wav files in the directories date-wise
'''
coswara_data_dir = os.path.abspath('.') # Local Path of iiscleap/Coswara-Data Repo
extracted_data_dir = os.path.join(coswara_data_dir, 'Extracted_data')
if not os.path.exists(coswara_data_dir):
raise("Check the Coswara dataset directory!")
if not os.path.exists(extracted_data_dir):
os.makedirs(extracted_data_dir) # Creates the Extracted_data folder if it doesn't exist
dirs_extracted = set(map(os.path.basename,glob.glob('{}/202*'.format(extracted_data_dir))))
dirs_all = set(map(os.path.basename,glob.glob('{}/202*'.format(coswara_data_dir))))
dirs_to_extract = list(set(dirs_all) - dirs_extracted)
for d in dirs_to_extract:
p = subprocess.Popen('cat {}/{}/*.tar.gz.* |tar -xvz -C {}/'.format(coswara_data_dir, d, extracted_data_dir), shell=True)
p.wait()
print("Extraction process complete!")