I have the transient object:
class new_import(models.TransientModel):
_name = 'new.import'
data_file = fields.Binary('File')
I call a wizard to load the file in the binary field and then i want to parse it.
In the function to parse the file i do:
data_file = base64.b64decode(self.data_file)
lines = data_file.split('\n')
for line in lines:
result = line[6:11]
but when i read the lines if there is a special character the length of the line isn't the same in all lines,
the file is utf8 in the origin
this must be an error when save the file in binary and then decode back to string
If i read the file directly with python with out store it in a binary field i can read it correctly:
codecs.open(file, mode='r', encoding='utf-8')
result = line[6:11].encode('utf-8')
How can i avoid storing the file in base64 or how can i after decode correctly to string?
Thanks in advance