def _pickle_array(arr): arr = arr.view(np.ndarray) buf = BytesIO() write_array(buf, arr) return buf.getvalue()
def test_sniff_delimiter(self): text = """index|A|B|C foo|1|2|3 bar|4|5|6 baz|7|8|9 """ data = read_csv(StringIO(text), index_col=0, sep=None) self.assert_(data.index.equals(Index(['foo', 'bar', 'baz']))) data2 = read_csv(StringIO(text), index_col=0, delimiter='|') assert_frame_equal(data, data2) text = """ignore this ignore this too index|A|B|C foo|1|2|3 bar|4|5|6 baz|7|8|9 """ data3 = read_csv(StringIO(text), index_col=0, sep=None, skiprows=2) assert_frame_equal(data, data3) # can't get this to work on Python 3 if not py3compat.PY3: text = u"""ignore this ignore this too index|A|B|C foo|1|2|3 bar|4|5|6 baz|7|8|9 """.encode('utf-8') data4 = read_csv(BytesIO(text), index_col=0, sep=None, skiprows=2, encoding='utf-8') assert_frame_equal(data, data4)
def test_StringIO(self): text = open(self.csv1, 'rb').read() src = BytesIO(text) reader = TextReader(src, header=None) result = reader.read()
def _unpickle_array(bytes): arr = read_array(BytesIO(bytes)) return arr