Skip to content

Instantly share code, notes, and snippets.

@cbare
Created February 15, 2016 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbare/0f97f71703c655fc05e5 to your computer and use it in GitHub Desktop.
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
"""
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