pandas.io.parsers.TextFileReader.get_chunk#
- TextFileReader.get_chunk(size=None)[source]#
Read the next chunk of rows from the file.
Convenience wrapper around
TextFileReader.read()that defaultssizeto thechunksizepassed toread_csv()orread_table(), and respects a configurednrowslimit by raisingStopIterationonce it has been reached.- Parameters:
- sizeint, optional
Number of rows to read in this chunk. Defaults to the
chunksizepassed when the reader was created.
- Returns:
- DataFrame
The next chunk of parsed rows.
- Raises:
- StopIteration
If
nrowswas set and has already been reached.
See also
TextFileReader.readRead rows from the file into a DataFrame.
read_csvRead a comma-separated values (csv) file into a DataFrame.
Examples
>>> with pd.read_csv("data.csv", iterator=True) as reader: ... first_five = reader.get_chunk(5)