-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalize_sc2_abc.py
55 lines (44 loc) · 1.09 KB
/
normalize_sc2_abc.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Maybe broken
import sys
import csv
import re
from itertools import islice
parameter = sys.argv
input_csv = parameter[1]
output_csv = parameter[2]
goodDataRows = []
def fixRows(input_csv):
global goodDataRows
headrow = []
headrow.append('Id')
headrow.append('Prompt')
headrow.append('Wavfile')
headrow.append('RecResult')
headrow.append('Transcription')
headrow.append('language')
headrow.append('meaning')
goodDataRows.append(headrow)
csv_file = open(input_csv)
reader = csv.reader(csv_file, delimiter='\t')
for row in reader:
if row[0] != 'Id':
new_row = []
new_row.append(row[0])
new_row.append(row[1])
new_row.append(row[2])
new_row.append(row[3])
new_row.append(row[4])
new_row.append(row[5])
new_row.append(row[6])
goodDataRows.append(new_row)
csv_file.close()
def writeTextFiles(input_csv):
global goodDataRows
file = open(input_csv, 'w')
writer = csv.writer(file, delimiter='\t', quotechar='"', quoting=csv.QUOTE_ALL)
for row in goodDataRows:
writer.writerow(row)
file.close()
# now run the methods
fixRows(input_csv)
writeTextFiles(output_csv)