The previous version here was using UnicodeReader which was
wrapping the UTF8Recoder class and passing that to csv.reader.
It looks like the intention was to read a bytestream in a
certain encoding and then reencode it to a different encoding.
And then UnicodeReader creates unicode from the newly encoded stream.
This is unnecssary, we know the encoding of the bytesstream and
codec.getreader will happily consume the bytstream and give back
unicode. The unicode can be fed directly into csv.writer.
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
def parse(self, contents):
self.lines = []
- reader = UnicodeReader(BytesIO(contents),
- encoding=self.encoding)
+ reader = csv.reader(codecs.getreader(self.encoding)(BytesIO(contents)))
- self.header = reader.next()
+ self.header = next(reader)
for row in reader:
line = {}
for i, x in enumerate(row):