Created
February 15, 2016 17:43
-
-
Save cbare/0f97f71703c655fc05e5 to your computer and use it in GitHub Desktop.
Take individual feature .csv files from mhealthx and output a combined feature table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Combine feature extraction output .csv files | |
""" | |
import csv | |
import os | |
dir = "/home/ubuntu/mhealthx_output/feature_tables/voice_openSMILE-2.2rc1_gemaps" | |
data=[] | |
for filename in os.listdir(dir): | |
print filename | |
path = os.path.join(dir, filename) | |
with open(path) as f: | |
reader = csv.reader(f) | |
header = next(reader) | |
row = next(reader) | |
row[12:] = [float(x) for x in row[12:]] | |
row = [a for i,a in enumerate(row) if i not in [0,11]] | |
data.append(row) | |
header = [a for i,a in enumerate(header) if i not in [0,11]] | |
with open('voice_gemaps.features.csv', 'w') as f: | |
writer = csv.writer(f) | |
writer.writerow(header) | |
for row in data: | |
writer.writerow(row) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment