16 self.
in_file = open(check2.csv_filename,
'rb')
26 def export(self, include_trans, progress_update_fcn=None, progress_next_fcn=None):
27 reader = csv.DictReader(self.
in_file)
28 extra_headers = [
'Child Voc',
'Word Count']
30 extra_headers.append(
'Transcription')
31 out_headers = reader.fieldnames + extra_headers
32 writer = csv.DictWriter(self.
out_file, out_headers)
43 for i
in range(len(self.check2.test2s)):
44 test2 = self.check2.test2s[i]
45 key = test2.child_code + test2.spreadsheet_timestamp
46 test2_dict[key] = (test2, i)
48 out_rows = [
None] * len(self.check2.test2s)
49 all_rows = list(reader)
53 while i < len(all_rows)
and match_count < len(self.check2.test2s):
56 month = BackendUtils.pad_num_str(row[
'month'])
57 day = BackendUtils.pad_num_str(row[
'day'])
58 elapsed_sec = row[
'Elapsed_Time']
59 key = Reliability2Parser.get_child_code(row) +
'%s %s %s %s' % (day, month, year, elapsed_sec)
61 row[extra_headers[0]] = test2_dict[key][0].child_vocs
62 row[extra_headers[1]] = BackendUtils.get_word_count(test2_dict[key][0].transcription)
64 row[extra_headers[2]] = test2_dict[key][0].transcription
67 out_rows[test2_dict[key][1]] = row
69 if progress_update_fcn:
70 progress_update_fcn(float(i + 1) / float(len(all_rows)))
76 for i
in range(len(out_rows)):
79 raise Exception(
'Unable to match Test2 object with input spreadsheet row. Has spreadsheet changed?')
83 if progress_update_fcn:
84 progress_update_fcn(float(i + 1) / float(len(out_rows)))