74
74
75
75
By file-like object, we refer to objects with a ``read()`` method, such as
76
76
a file handler (e.g. via builtin ``open`` function) or ``StringIO``.
77
- {sep_doc}
77
+ sep : str, default {_default_sep}
78
+ Delimiter to use. If sep is None, the C engine cannot automatically detect
79
+ the separator, but the Python parsing engine can, meaning the latter will
80
+ be used and automatically detect the separator by Python's builtin sniffer
81
+ tool, ``csv.Sniffer``. In addition, separators longer than 1 character and
82
+ different from ``'\s+'`` will be interpreted as regular expressions and
83
+ will also force the use of the Python parsing engine. Note that regex
84
+ delimiters are prone to ignoring quoted data. Regex example: ``'\r\t'``.
85
+ delimiter : str, default ``None``
86
+ Alias for sep.
78
87
header : int or list of ints, default 'infer'
79
88
Row number(s) to use as the column names, and the start of the
80
89
data. Default behavior is to infer the column names: if no names
130
139
to preserve and not interpret dtype.
131
140
If converters are specified, they will be applied INSTEAD
132
141
of dtype conversion.
133
- {engine_doc}
142
+ engine : {{'c', 'python'}}, optional
143
+ Parser engine to use. The C engine is faster while the python engine is
144
+ currently more feature-complete.
134
145
converters : dict, default None
135
146
Dict of functions for converting values in certain columns. Keys can either
136
147
be integers or column labels.
326
337
>>> pd.{func_name}('data.csv') # doctest: +SKIP
327
338
"""
328
339
329
- # engine is not used in read_fwf() so is factored out of the shared docstring
330
- _engine_doc = """engine : {'c', 'python'}, optional
331
- Parser engine to use. The C engine is faster while the python engine is
332
- currently more feature-complete."""
333
-
334
- _sep_doc = r"""sep : str, default {default}
335
- Delimiter to use. If sep is None, the C engine cannot automatically detect
336
- the separator, but the Python parsing engine can, meaning the latter will
337
- be used and automatically detect the separator by Python's builtin sniffer
338
- tool, ``csv.Sniffer``. In addition, separators longer than 1 character and
339
- different from ``'\s+'`` will be interpreted as regular expressions and
340
- will also force the use of the Python parsing engine. Note that regex
341
- delimiters are prone to ignoring quoted data. Regex example: ``'\r\t'``.
342
- delimiter : str, default ``None``
343
- Alias for sep.
344
- """
345
-
346
340
347
341
def _validate_integer (name , val , min_val = 0 ):
348
342
"""
@@ -710,8 +704,7 @@ def parser_f(filepath_or_buffer,
710
704
func_name = 'read_csv' ,
711
705
summary = ('Read a comma-separated values (csv) file '
712
706
'into DataFrame.' ),
713
- sep_doc = _sep_doc .format (default = "','" ),
714
- engine_doc = _engine_doc )
707
+ _default_sep = "','" )
715
708
)(read_csv )
716
709
717
710
read_table = _make_parser_function ('read_table' , default_sep = '\t ' )
@@ -721,8 +714,7 @@ def parser_f(filepath_or_buffer,
721
714
722
715
.. deprecated:: 0.24.0
723
716
Use :func:`pandas.read_csv` instead, passing ``sep='\\ t'`` if necessary.""" ,
724
- sep_doc = _sep_doc .format (default = "\\ t (tab-stop)" ),
725
- engine_doc = _engine_doc )
717
+ _default_sep = r'\\t (tab-stop)' )
726
718
)(read_table )
727
719
728
720
0 commit comments