Skip to content

Commit

Permalink
TST: unit test to try to replicate #2298
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Dec 2, 2012
1 parent 86806fc commit 7e2a47d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def _should_parse_dates(self, i):
return (j in self.parse_dates) or (name in self.parse_dates)

def _make_index(self, data, alldata, columns):
if self.index_col is None:
if self.index_col is None or len(self.index_col) == 0:
index = None

elif not self._has_complex_date_col:
Expand Down
26 changes: 26 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,32 @@ def test_skipinitialspace(self):
header=None, skipinitialspace=True)
self.assertTrue(pd.isnull(result.ix[0, 29]))

def test_utf16_bom_skiprows(self):
# #2298
data = u"""skip this
skip this too
A,B,C\n
1,2,3
4,5,6"""
path = '__%s__.csv' % tm.rands(10)

for enc in ['utf-16', 'utf-16le', 'utf-16be']:
bytes = data.encode(enc)
with open(path, 'wb') as f:
f.write(bytes)

result = self.read_csv(path, encoding=enc, skiprows=2)
expected = self.read_csv(StringIO(data.encode('utf-8')),
encoding='utf-8', skiprows=2)

tm.assert_frame_equal(result, expected)

try:
os.remove(path)
except os.error:
pass


class TestCParserHighMemory(ParserTests, unittest.TestCase):

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

0 comments on commit 7e2a47d

Please sign in to comment.