34
34
'link_ids': fields.one2many('ea_import.chain.link', 'chain_id', 'Chain Links', ),
35
35
'result_ids': fields.one2many('ea_import.chain.result', 'chain_id', 'Import Results', ),
36
36
'separator': fields.selection([
38
38
(";", '<;> - Semicolon'),
39
39
("\t", '<TAB> - Tab'),
40
40
(" ", '<SPACE> - Space'),
41
], 'Separator', required=True),
42
42
'delimiter': fields.selection([
43
43
("'", '<\'> - Single quotation mark'),
44
44
('"', '<"> - Double quotation mark'),
46
], 'Delimiter', required=True),
47
'charset': fields.selection([
48
('us-ascii', 'US-ASCII'),
49
('utf-7', 'Unicode (UTF-7)'),
50
('utf-8', 'Unicode (UTF-8)'),
51
('utf-16', 'Unicode (UTF-16)'),
52
('windows-1250', 'Central European (Windows)'),
53
('iso-8859-1', 'Western European (ISO)'),
54
('iso-8859-15', 'Latin 9 (ISO)'),
55
], 'Encoding', required=True)
85
95
input_file = StringIO(base64.b64decode(chain.input_file))
86
96
for string_record in input_file:
88
for field_string in string_record.split(chain.separator):
98
for field_string in string_record.decode(chain.charset).split(chain.separator):
89
99
delimiter = chain.delimiter and chain.delimiter + "\n\r" or "\n\r"
90
100
line.append(field_string.strip(delimiter))
91
101
result.append(line)