Skip to content

Commit fd4c4c9

Browse files
committed
DOC: update read_csv docs
1 parent 17f5ef9 commit fd4c4c9

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

RELEASE.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ analysis / manipulation tool available in any language.
1818
Where to get it
1919
---------------
2020

21-
Source code: http://github.com/wesm/pandas
22-
Binary installers on PyPI: http://pypi.python.org/pypi/pandas
23-
Documentation: http://pandas.sourceforge.net
21+
* Source code: http://github.com/wesm/pandas
22+
* Binary installers on PyPI: http://pypi.python.org/pypi/pandas
23+
* Documentation: http://pandas.sourceforge.net
2424

2525
pandas 0.5.0
2626
============

pandas/io/parsers.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,17 @@ def read_csv(filepath_or_buffer, sep=None, header=0, index_col=None, names=None,
6262

6363
def read_table(filepath_or_buffer, sep='\t', header=0, index_col=None,
6464
names=None, skiprows=None, na_values=None, parse_dates=False,
65-
date_parser=None):
65+
date_parser=None, nrows=None, iterator=False, chunksize=None):
6666
return read_csv(filepath_or_buffer, sep=sep, header=header,
6767
skiprows=skiprows, index_col=index_col,
6868
na_values=na_values, date_parser=date_parser,
69-
names=names, parse_dates=parse_dates)
69+
names=names, parse_dates=parse_dates,
70+
nrows=nrows, iterator=iterator, chunksize=chunksize)
7071

71-
_parser_params = """Parameters
72+
_parser_params = """Also supports optionally iterating or breaking of the file
73+
into chunks.
74+
75+
Parameters
7276
----------
7377
filepath_or_buffer : string or file handle / StringIO
7478
%s
@@ -79,15 +83,26 @@ def read_table(filepath_or_buffer, sep='\t', header=0, index_col=None,
7983
index_col : int or sequence, default None
8084
Column to use as the row labels of the DataFrame. If a sequence is
8185
given, a MultiIndex is used.
86+
names : array-like
87+
List of column names
8288
na_values : list-like, default None
8389
List of additional strings to recognize as NA/NaN
8490
parse_dates : boolean, default False
8591
Attempt to parse dates in the index column(s)
8692
date_parser : function
8793
Function to use for converting dates to strings. Defaults to
8894
dateutil.parser
89-
names : array-like
90-
List of column names"""
95+
nrows : int, default None
96+
Number of rows of file to read. Useful for reading pieces of large files
97+
iterator : boolean, default False
98+
Return TextParser object
99+
chunksize : int, default None
100+
Return TextParser object for iteration
101+
102+
Returns
103+
-------
104+
result : DataFrame or TextParser
105+
"""
91106

92107
_csv_sep = """sep : string, default None
93108
Delimiter to use. By default will try to automatically determine

pandas/io/tests/test_parsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def test_read_chunksize(self):
239239

240240
def test_iterator(self):
241241
reader = read_csv(StringIO(self.data1), index_col=0, iterator=True)
242+
242243
df = read_csv(StringIO(self.data1), index_col=0)
243244

244245
chunk = reader.get_chunk(3)
@@ -258,6 +259,10 @@ def test_iterator(self):
258259
assert_frame_equal(chunks[1], df[2:4])
259260
assert_frame_equal(chunks[2], df[4:])
260261

262+
treader = read_table(StringIO(self.data1), sep=',', index_col=0,
263+
iterator=True)
264+
self.assert_(isinstance(treader, TextParser))
265+
261266
def test_header_not_first_line(self):
262267
data = """got,to,ignore,this,line
263268
got,to,ignore,this,line

0 commit comments

Comments
 (0)