1212)
1313import csv
1414import sys
15+ from textwrap import fill
1516from typing import (
1617 IO ,
1718 TYPE_CHECKING ,
3536 ParserWarning ,
3637)
3738from pandas .util ._decorators import (
39+ Appender ,
3840 set_module ,
3941)
4042from pandas .util ._exceptions import find_stack_level
5153from pandas import Series
5254from pandas .core .frame import DataFrame
5355from pandas .core .indexes .api import RangeIndex
56+ from pandas .core .shared_docs import _shared_docs
5457
5558from pandas .io .common import (
5659 IOHandles ,
@@ -910,7 +913,7 @@ def read_csv(
910913 If ``converters`` are specified, they will be applied INSTEAD
911914 of ``dtype`` conversion.
912915
913- .. versionadded:: 1.5.0
916+ versionadded:: 1.5.0
914917 Support for ``defaultdict`` was added. Specify a ``defaultdict`` as input
915918 where
916919 the default determines the ``dtype`` of the columns which are not explicitly
@@ -922,7 +925,7 @@ def read_csv(
922925 Multithreading is currently only supported by
923926 the pyarrow engine.
924927
925- .. versionadded:: 1.4.0
928+ versionadded:: 1.4.0
926929 The 'pyarrow' engine was added as an *experimental* engine,
927930 and some features
928931 are unsupported, or may not work correctly, with this engine.
@@ -1022,7 +1025,7 @@ def read_csv(
10221025 - "mixed", to infer the format for each element individually. This is risky,
10231026 and you should probably use it along with `dayfirst`.
10241027
1025- .. versionadded:: 2.0.0
1028+ versionadded:: 2.0.0
10261029 dayfirst : bool, default False
10271030 DD/MM format dates, international and European format.
10281031 cache_dates : bool, default True
@@ -1056,10 +1059,10 @@ def read_csv(
10561059 decompression using a custom compression dictionary:
10571060 ``compression={'method': 'zstd', 'dict_data': my_compression_dict}``.
10581061
1059- .. versionadded:: 1.5.0
1062+ versionadded:: 1.5.0
10601063 Added support for `.tar` files.
10611064
1062- .. versionchanged:: 1.4.0 Zstandard support.
1065+ versionchanged:: 1.4.0 Zstandard support.
10631066 thousands : str (length 1), optional
10641067 Character acting as the thousands separator in numerical values.
10651068 decimal : str (length 1), default '.'
@@ -1101,7 +1104,7 @@ def read_csv(
11011104 How encoding errors are treated. `List of possible values
11021105 <https://docs.python.org/3/library/codecs.html#error-handlers>`_.
11031106
1104- .. versionadded:: 1.3.0
1107+ versionadded:: 1.3.0
11051108 dialect : str or csv.Dialect, optional
11061109 If provided, this parameter will override values (default or not)
11071110 for the following parameters: ``delimiter``, ``doublequote``,
@@ -1132,12 +1135,12 @@ def read_csv(
11321135 <https://arrow.apache.org/docs/python/generated/pyarrow.csv.ParseOptions.html
11331136 #pyarrow.csv.ParseOptions.invalid_row_handler>`_.
11341137
1135- .. versionadded:: 1.3.0
1138+ versionadded:: 1.3.0
11361139
1137- .. versionadded:: 1.4.0
1140+ versionadded:: 1.4.0
11381141 Callable
11391142
1140- .. versionchanged:: 2.2.0
1143+ versionchanged:: 2.2.0
11411144 Callable for ``engine='pyarrow'``
11421145 low_memory : bool, default True
11431146 Internally process the file in chunks, resulting in lower memory
@@ -1179,7 +1182,7 @@ def read_csv(
11791182 * ``"pyarrow"``: returns pyarrow-backed nullable
11801183 :class:`ArrowDtype` :class:`DataFrame`
11811184
1182- .. versionadded:: 2.0
1185+ versionadded:: 2.0
11831186
11841187 Returns
11851188 -------
@@ -1489,7 +1492,7 @@ def read_table(
14891492 If ``converters`` are specified, they will be applied INSTEAD
14901493 of ``dtype`` conversion.
14911494
1492- .. versionadded:: 1.5.0
1495+ versionadded:: 1.5.0
14931496 Support for ``defaultdict`` was added. Specify a ``defaultdict``
14941497 as input where the default determines the ``dtype`` of the
14951498 columns which are not explicitly listed.
@@ -1498,7 +1501,7 @@ def read_table(
14981501 the python engine is currently more feature-complete. Multithreading
14991502 is currently only supported by the pyarrow engine.
15001503
1501- .. versionadded:: 1.4.0
1504+ versionadded:: 1.4.0
15021505 The 'pyarrow' engine was added as an *experimental* engine, and
15031506 some features are unsupported, or may not work correctly, with
15041507 this engine.
@@ -1602,7 +1605,7 @@ def read_table(
16021605 - "mixed", to infer the format for each element individually. This
16031606 is risky, and you should probably use it along with `dayfirst`.
16041607
1605- .. versionadded:: 2.0.0
1608+ versionadded:: 2.0.0
16061609 dayfirst : bool, default False
16071610 DD/MM format dates, international and European format.
16081611 cache_dates : bool, default True
@@ -1635,10 +1638,10 @@ def read_table(
16351638 decompression using a custom compression dictionary:
16361639 ``compression={'method': 'zstd', 'dict_data': my_compression_dict}``.
16371640
1638- .. versionadded:: 1.5.0
1641+ versionadded:: 1.5.0
16391642 Added support for `.tar` files.
16401643
1641- .. versionchanged:: 1.4.0 Zstandard support.
1644+ versionchanged:: 1.4.0 Zstandard support.
16421645 thousands : str (length 1), optional
16431646 Character acting as the thousands separator in numerical values.
16441647 decimal : str (length 1), default '.'
@@ -1679,7 +1682,7 @@ def read_table(
16791682 How encoding errors are treated. `List of possible values
16801683 <https://docs.python.org/3/library/codecs.html#error-handlers>`_.
16811684
1682- .. versionadded:: 1.3.0
1685+ versionadded:: 1.3.0
16831686 dialect : str or csv.Dialect, optional
16841687 If provided, this parameter will override values (default or not)
16851688 for the following parameters: ``delimiter``, ``doublequote``,
@@ -1708,12 +1711,12 @@ def read_table(
17081711 <https://arrow.apache.org/docs/python/generated/pyarrow.csv.ParseOptions.html
17091712 #pyarrow.csv.ParseOptions.invalid_row_handler>`_.
17101713
1711- .. versionadded:: 1.3.0
1714+ versionadded:: 1.3.0
17121715
1713- .. versionadded:: 1.4.0
1716+ versionadded:: 1.4.0
17141717 Callable
17151718
1716- .. versionchanged:: 2.2.0
1719+ versionchanged:: 2.2.0
17171720 Callable for ``engine='pyarrow'``
17181721 low_memory : bool, default True
17191722 Internally process the file in chunks, resulting in lower memory use
@@ -1754,7 +1757,7 @@ def read_table(
17541757 * ``"pyarrow"``: returns pyarrow-backed nullable
17551758 :class:`ArrowDtype` :class:`DataFrame`
17561759
1757- .. versionadded:: 2.0
1760+ versionadded:: 2.0
17581761
17591762 Returns
17601763 -------
@@ -1848,24 +1851,6 @@ def read_table(
18481851 col 3 datetime64[ns]
18491852 dtype: object
18501853 """
1851- # locals() should never be modified
1852- kwds = locals ().copy ()
1853- del kwds ["filepath_or_buffer" ]
1854- del kwds ["sep" ]
1855-
1856- kwds_defaults = _refine_defaults_read (
1857- dialect ,
1858- delimiter ,
1859- engine ,
1860- sep ,
1861- on_bad_lines ,
1862- names ,
1863- defaults = {"delimiter" : "\t " },
1864- dtype_backend = dtype_backend ,
1865- )
1866- kwds .update (kwds_defaults )
1867-
1868- return _read (filepath_or_buffer , kwds )
18691854
18701855
18711856@overload
@@ -2399,8 +2384,7 @@ def read(self, nrows: int | None = None) -> DataFrame:
23992384 dtype_arg = None
24002385
24012386 if isinstance (dtype_arg , dict ):
2402- # type: ignore[var-annotated]
2403- dtype = defaultdict (lambda : None )
2387+ dtype = defaultdict (lambda : None ) # type: ignore[var-annotated]
24042388 dtype .update (dtype_arg )
24052389 elif dtype_arg is not None and pandas_dtype (dtype_arg ) in (
24062390 np .str_ ,
@@ -2712,8 +2696,7 @@ def _extract_dialect(kwds: dict[str, str | csv.Dialect]) -> csv.Dialect | None:
27122696
27132697 dialect = kwds ["dialect" ]
27142698 if isinstance (dialect , str ) and dialect in csv .list_dialects ():
2715- # get_dialect is typed to return a `_csv.Dialect` for some reason in
2716- # typeshed
2699+ # get_dialect is typed to return a `_csv.Dialect` for some reason in typeshed
27172700 tdialect = cast (csv .Dialect , csv .get_dialect (dialect ))
27182701 _validate_dialect (tdialect )
27192702
0 commit comments