|
a |
|
b/2csv.py |
|
|
1 |
# this script convert the full dataset mitdb to .csv |
|
|
2 |
|
|
|
3 |
from os import listdir, mkdir, system |
|
|
4 |
from os.path import isfile, isdir, join, exists |
|
|
5 |
|
|
|
6 |
dir = '/local/scratch/mondejar/dataset/mitdb/' |
|
|
7 |
#Create folder |
|
|
8 |
csv = dir + 'csv' |
|
|
9 |
if not exists(csv): |
|
|
10 |
mkdir(csv) |
|
|
11 |
|
|
|
12 |
records = [f for f in listdir(dir) if isfile(join(dir, f)) if(f.find('.dat') != -1)] |
|
|
13 |
#print records |
|
|
14 |
|
|
|
15 |
for r in records: |
|
|
16 |
|
|
|
17 |
command = 'rdsamp -r ' + r[:-4] + ' -c -H -f 0 -v >' + 'csv/' + r[:-4] + '.csv' |
|
|
18 |
print(command) |
|
|
19 |
system(command) |
|
|
20 |
|
|
|
21 |
command_annotations = 'rdann -r ' + r[:-4] +' -f 0 -a atr -v >' + 'csv/' + r[:-4] + 'annotations.txt' |
|
|
22 |
print(command_annotations) |
|
|
23 |
system(command_annotations) |