Skip to content

Commit

Permalink
test read_csv with header=None
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Apr 30, 2016
1 parent 864492f commit 6a477d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dask/dataframe/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ def read_csv(filename, blocksize=2**25, chunkbytes=None,
if 'nrows' in kwargs:
values = [[values[0][0]]]

header = sample.split(b_lineterminator)[0] + b_lineterminator
if kwargs.get('header', 'infer') is None:
header = b''
else:
header = sample.split(b_lineterminator)[0] + b_lineterminator
head = pd.read_csv(BytesIO(sample), **kwargs)

df = read_csv_from_bytes(values, header, head, kwargs,
Expand Down
9 changes: 9 additions & 0 deletions dask/dataframe/tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,12 @@ def test_late_dtypes():

assert df.a.sum().compute() == 1 + 2 + 3 + 4 + 5.5 + 6
assert df.b.sum().compute() == 2 + 3 + 4 + 5 + 6 + 7.5


def test_header_None():
with filetexts({'.tmp.1.csv': '1,2',
'.tmp.2.csv': '',
'.tmp.3.csv': '3,4'}):
df = read_csv('.tmp.*.csv', header=None)
expected = pd.DataFrame({0: [1, 3], 1: [2, 4]})
eq(df.compute().reset_index(drop=True), expected)

0 comments on commit 6a477d9

Please sign in to comment.