Skip to content

Commit

Permalink
BUG: move utf8 recoding elsewhere, add test case to deal with #2298
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Dec 6, 2012
1 parent f985aa1 commit 4e49d29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,6 @@ def _get_handle(path, mode, encoding=None):
f = open(path, mode, errors='replace')
else:
f = open(path, mode)
if encoding is not None and 'r' in mode:
f = UTF8Recoder(f, encoding)
return f

if py3compat.PY3: # pragma: no cover
Expand All @@ -1118,7 +1116,7 @@ class UnicodeReader:
"""

def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
# f = UTF8Recoder(f, encoding)
f = UTF8Recoder(f, encoding)
self.reader = csv.reader(f, dialect=dialect, **kwds)

def next(self):
Expand Down
4 changes: 4 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,10 @@ def test_utf16_example(self):
result = self.read_table(path, encoding='utf-16')
self.assertEquals(len(result), 50)

buf = BytesIO(open(path, 'rb').read())
result = self.read_table(buf, encoding='utf-16')
self.assertEquals(len(result), 50)

class TestCParserHighMemory(ParserTests, unittest.TestCase):

def read_csv(self, *args, **kwds):
Expand Down

0 comments on commit 4e49d29

Please sign in to comment.