U °Dx`A"ã2@søUdZddlmZmZddlZddlZddlmZddlZddl Z ddl Z ddl m Z ddl mZmZmZmZmZmZmZmZmZmZddlZddlZddlmmZddlmmZ ddl!mm"Z"ddl!m#Z#ddl$m%Z%dd l&m'Z'm(Z(m)Z)dd l*m+Z+m,Z,m-Z-m.Z.dd l/m0Z0dd l1m2Z2dd l3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCddlDmEZEddlFmGZGddlHmIZImJZJddlKmLZLddlMmNZNddlOmPZPmQZQmRZRmSZSddlTmUZUddlVmWZXddlYmZZZm[Z[m\Z\ddl]m^Z^dZ_de d `eae#ƒ¡ddd�dZbd…dd „Zcd!d"„Zde'd#œd$d%„Zeddd&ejfd'd(dd)dddddddd'ddddd'ddd*d(d(d(dddd(dd(dd'd(d'd+œ%Zgd(d'd'd(d'd'dd,œZhd)d-dd.œZid/hZjd0d1hZkiZleemefend2<eoƒZpeemend3<e0ebjqd4d5d6eJjrd7d8�ƒejsdd)dddd(dd'dddddd(ddddd'd'd(d'd(d(d(dd(d'd(dd)dd*dd&ejfd'ddddd'd'd(ehd0d(ddf1e'eme(d9œd:d4„ƒZte0ebjqd;dœd?d;„ƒZud†e'd#œd@dA„ZvGdBdC„dCejƒZwdDdE„Zxd‡ee)eyeezfdFœdGdH„Z{dIdJ„Z|dKdL„Z}dMdN„Z~dOdP„ZdQdR„Z€GdSdT„dTƒZ�GdUdV„dVe�ƒZ‚dWdX„ZƒezdYœdZd[„Z„Gd\d]„d]e�ƒZ…dˆd^d_„Z†d‰d`da„Z‡dbdc„ZˆdŠddde„Z‰dfdg„ZŠd‹dhdi„Z‹djdk„ZŒdldm„Z�dndo„ZŽdpdq„Z�Gdrds„dsejƒZ�Gdtdu„due…ƒZ‘e)emej’fe)eme“feyeme)eme“feemefdvœdwdx„Z”eemefeej’dyœdzd{„Z•d|Z–ej’dd}œd~d„Z—ej’eemefeemefd€œd�d‚„Z˜eemefddyœdƒd„„Z™dS)ŒzM Module contains tools for processing files into DataFrames or other objects é)ÚabcÚ defaultdictN)ÚStringIO)Úfill) ÚAnyÚDictÚIterableÚIteratorÚListÚOptionalÚSequenceÚSetÚTypeÚcast)Ú STR_NA_VALUES)Úparsing)ÚFilePathOrBufferÚStorageOptionsÚUnion)ÚAbstractMethodErrorÚEmptyDataErrorÚ ParserErrorÚ ParserWarning)ÚAppender)Úastype_nansafe)Ú ensure_objectÚ ensure_strÚ is_bool_dtypeÚis_categorical_dtypeÚ is_dict_likeÚis_dtype_equalÚis_extension_array_dtypeÚ is_file_likeÚis_floatÚ is_integerÚis_integer_dtypeÚ is_list_likeÚis_object_dtypeÚ is_scalarÚis_string_dtypeÚ pandas_dtype)ÚCategoricalDtype)Úisna)Ú algorithmsÚgeneric)Ú Categorical)Ú DataFrame)ÚIndexÚ MultiIndexÚ RangeIndexÚensure_index_from_sequences©ÚSeries)Ú datetimes)Ú IOHandlesÚ get_handleÚvalidate_header_arg)Úgeneric_parseruaÜ {summary} Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the online docs for `IO Tools `_. Parameters ---------- filepath_or_buffer : str, path object or file-like object Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, gs, and file. For file URLs, a host is expected. A local file could be: file://localhost/path/to/table.csv. If you want to pass in a path object, pandas accepts any ``os.PathLike``. By file-like object, we refer to objects with a ``read()`` method, such as a file handle (e.g. via builtin ``open`` function) or ``StringIO``. sep : str, default {_default_sep} Delimiter to use. If sep is None, the C engine cannot automatically detect the separator, but the Python parsing engine can, meaning the latter will be used and automatically detect the separator by Python's builtin sniffer tool, ``csv.Sniffer``. In addition, separators longer than 1 character and different from ``'\s+'`` will be interpreted as regular expressions and will also force the use of the Python parsing engine. Note that regex delimiters are prone to ignoring quoted data. Regex example: ``'\r\t'``. delimiter : str, default ``None`` Alias for sep. header : int, list of int, default 'infer' Row number(s) to use as the column names, and the start of the data. Default behavior is to infer the column names: if no names are passed the behavior is identical to ``header=0`` and column names are inferred from the first line of the file, if column names are passed explicitly then the behavior is identical to ``header=None``. Explicitly pass ``header=0`` to be able to replace existing names. The header can be a list of integers that specify row locations for a multi-index on the columns e.g. [0,1,3]. Intervening rows that are not specified will be skipped (e.g. 2 in this example is skipped). Note that this parameter ignores commented lines and empty lines if ``skip_blank_lines=True``, so ``header=0`` denotes the first line of data rather than the first line of the file. names : array-like, optional List of column names to use. If the file contains a header row, then you should explicitly pass ``header=0`` to override the column names. Duplicates in this list are not allowed. index_col : int, str, sequence of int / str, or False, default ``None`` Column(s) to use as the row labels of the ``DataFrame``, either given as string name or column index. If a sequence of int / str is given, a MultiIndex is used. Note: ``index_col=False`` can be used to force pandas to *not* use the first column as the index, e.g. when you have a malformed file with delimiters at the end of each line. usecols : list-like or callable, optional Return a subset of the columns. If list-like, all elements must either be positional (i.e. integer indices into the document columns) or strings that correspond to column names provided either by the user in `names` or inferred from the document header row(s). For example, a valid list-like `usecols` parameter would be ``[0, 1, 2]`` or ``['foo', 'bar', 'baz']``. Element order is ignored, so ``usecols=[0, 1]`` is the same as ``[1, 0]``. To instantiate a DataFrame from ``data`` with element order preserved use ``pd.read_csv(data, usecols=['foo', 'bar'])[['foo', 'bar']]`` for columns in ``['foo', 'bar']`` order or ``pd.read_csv(data, usecols=['foo', 'bar'])[['bar', 'foo']]`` for ``['bar', 'foo']`` order. If callable, the callable function will be evaluated against the column names, returning names where the callable function evaluates to True. An example of a valid callable argument would be ``lambda x: x.upper() in ['AAA', 'BBB', 'DDD']``. Using this parameter results in much faster parsing time and lower memory usage. squeeze : bool, default False If the parsed data only contains one column then return a Series. prefix : str, optional Prefix to add to column numbers when no header, e.g. 'X' for X0, X1, ... mangle_dupe_cols : bool, default True Duplicate columns will be specified as 'X', 'X.1', ...'X.N', rather than 'X'...'X'. Passing in False will cause data to be overwritten if there are duplicate names in the columns. dtype : Type name or dict of column -> type, optional Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32, 'c': 'Int64'}} Use `str` or `object` together with suitable `na_values` settings to preserve and not interpret dtype. If converters are specified, they will be applied INSTEAD of dtype conversion. engine : {{'c', 'python'}}, optional Parser engine to use. The C engine is faster while the python engine is currently more feature-complete. converters : dict, optional Dict of functions for converting values in certain columns. Keys can either be integers or column labels. true_values : list, optional Values to consider as True. false_values : list, optional Values to consider as False. skipinitialspace : bool, default False Skip spaces after delimiter. skiprows : list-like, int or callable, optional Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file. If callable, the callable function will be evaluated against the row indices, returning True if the row should be skipped and False otherwise. An example of a valid callable argument would be ``lambda x: x in [0, 2]``. skipfooter : int, default 0 Number of lines at bottom of file to skip (Unsupported with engine='c'). nrows : int, optional Number of rows of file to read. Useful for reading pieces of large files. na_values : scalar, str, list-like, or dict, optional Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values. By default the following values are interpreted as NaN: 'z', 'éFz )Úsubsequent_indenta$'. keep_default_na : bool, default True Whether or not to include the default NaN values when parsing the data. Depending on whether `na_values` is passed in, the behavior is as follows: * If `keep_default_na` is True, and `na_values` are specified, `na_values` is appended to the default NaN values used for parsing. * If `keep_default_na` is True, and `na_values` are not specified, only the default NaN values are used for parsing. * If `keep_default_na` is False, and `na_values` are specified, only the NaN values specified `na_values` are used for parsing. * If `keep_default_na` is False, and `na_values` are not specified, no strings will be parsed as NaN. Note that if `na_filter` is passed in as False, the `keep_default_na` and `na_values` parameters will be ignored. na_filter : bool, default True Detect missing value markers (empty strings and the value of na_values). In data without any NAs, passing na_filter=False can improve the performance of reading a large file. verbose : bool, default False Indicate number of NA values placed in non-numeric columns. skip_blank_lines : bool, default True If True, skip over blank lines rather than interpreting as NaN values. parse_dates : bool or list of int or names or list of lists or dict, default False The behavior is as follows: * boolean. If True -> try parsing the index. * list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 each as a separate date column. * list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as a single date column. * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call result 'foo' If a column or index cannot be represented as an array of datetimes, say because of an unparsable value or a mixture of timezones, the column or index will be returned unaltered as an object data type. For non-standard datetime parsing, use ``pd.to_datetime`` after ``pd.read_csv``. To parse an index or column with a mixture of timezones, specify ``date_parser`` to be a partially-applied :func:`pandas.to_datetime` with ``utc=True``. See :ref:`io.csv.mixed_timezones` for more. Note: A fast-path exists for iso8601-formatted dates. infer_datetime_format : bool, default False If True and `parse_dates` is enabled, pandas will attempt to infer the format of the datetime strings in the columns, and if it can be inferred, switch to a faster method of parsing them. In some cases this can increase the parsing speed by 5-10x. keep_date_col : bool, default False If True and `parse_dates` specifies combining multiple columns then keep the original columns. date_parser : function, optional Function to use for converting a sequence of string columns to an array of datetime instances. The default uses ``dateutil.parser.parser`` to do the conversion. Pandas will try to call `date_parser` in three different ways, advancing to the next if an exception occurs: 1) Pass one or more arrays (as defined by `parse_dates`) as arguments; 2) concatenate (row-wise) the string values from the columns defined by `parse_dates` into a single array and pass that; and 3) call `date_parser` once for each row using one or more strings (corresponding to the columns defined by `parse_dates`) as arguments. dayfirst : bool, default False DD/MM format dates, international and European format. cache_dates : bool, default True If True, use a cache of unique, converted dates to apply the datetime conversion. May produce significant speed-up when parsing duplicate date strings, especially ones with timezone offsets. .. versionadded:: 0.25.0 iterator : bool, default False Return TextFileReader object for iteration or getting chunks with ``get_chunk()``. .. versionchanged:: 1.2 ``TextFileReader`` is a context manager. chunksize : int, optional Return TextFileReader object for iteration. See the `IO Tools docs `_ for more information on ``iterator`` and ``chunksize``. .. versionchanged:: 1.2 ``TextFileReader`` is a context manager. compression : {{'infer', 'gzip', 'bz2', 'zip', 'xz', None}}, default 'infer' For on-the-fly decompression of on-disk data. If 'infer' and `filepath_or_buffer` is path-like, then detect compression from the following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no decompression). If using 'zip', the ZIP file must contain only one data file to be read in. Set to None for no decompression. thousands : str, optional Thousands separator. decimal : str, default '.' Character to recognize as decimal point (e.g. use ',' for European data). lineterminator : str (length 1), optional Character to break file into lines. Only valid with C parser. quotechar : str (length 1), optional The character used to denote the start and end of a quoted item. Quoted items can include the delimiter and it will be ignored. quoting : int or csv.QUOTE_* instance, default 0 Control field quoting behavior per ``csv.QUOTE_*`` constants. Use one of QUOTE_MINIMAL (0), QUOTE_ALL (1), QUOTE_NONNUMERIC (2) or QUOTE_NONE (3). doublequote : bool, default ``True`` When quotechar is specified and quoting is not ``QUOTE_NONE``, indicate whether or not to interpret two consecutive quotechar elements INSIDE a field as a single ``quotechar`` element. escapechar : str (length 1), optional One-character string used to escape other characters. comment : str, optional Indicates remainder of line should not be parsed. If found at the beginning of a line, the line will be ignored altogether. This parameter must be a single character. Like empty lines (as long as ``skip_blank_lines=True``), fully commented lines are ignored by the parameter `header` but not by `skiprows`. For example, if ``comment='#'``, parsing ``#empty\na,b,c\n1,2,3`` with ``header=0`` will result in 'a,b,c' being treated as the header. encoding : str, optional Encoding to use for UTF when reading/writing (ex. 'utf-8'). `List of Python standard encodings `_ . .. versionchanged:: 1.2 When ``encoding`` is ``None``, ``errors="replace"`` is passed to ``open()``. Otherwise, ``errors="strict"`` is passed to ``open()``. This behavior was previously only the case for ``engine="python"``. dialect : str or csv.Dialect, optional If provided, this parameter will override values (default or not) for the following parameters: `delimiter`, `doublequote`, `escapechar`, `skipinitialspace`, `quotechar`, and `quoting`. If it is necessary to override values, a ParserWarning will be issued. See csv.Dialect documentation for more details. error_bad_lines : bool, default True Lines with too many fields (e.g. a csv line with too many commas) will by default cause an exception to be raised, and no DataFrame will be returned. If False, then these "bad lines" will dropped from the DataFrame that is returned. warn_bad_lines : bool, default True If error_bad_lines is False, and warn_bad_lines is True, a warning for each "bad line" will be output. delim_whitespace : bool, default False Specifies whether or not whitespace (e.g. ``' '`` or ``' '``) will be used as the sep. Equivalent to setting ``sep='\s+'``. If this option is set to True, nothing should be passed in for the ``delimiter`` parameter. low_memory : bool, default True Internally process the file in chunks, resulting in lower memory use while parsing, but possibly mixed type inference. To ensure no mixed types either set False, or specify the type with the `dtype` parameter. Note that the entire file is read into a single DataFrame regardless, use the `chunksize` or `iterator` parameter to return the data in chunks. (Only valid with C parser). memory_map : bool, default False If a filepath is provided for `filepath_or_buffer`, map the file object directly onto memory and access the data directly from there. Using this option can improve performance because there is no longer any I/O overhead. float_precision : str, optional Specifies which converter the C engine should use for floating-point values. The options are ``None`` or 'high' for the ordinary converter, 'legacy' for the original lower precision pandas converter, and 'round_trip' for the round-trip converter. .. versionchanged:: 1.2 {storage_options} .. versionadded:: 1.2 Returns ------- DataFrame or TextParser A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes. See Also -------- DataFrame.to_csv : Write DataFrame to a comma-separated values (csv) file. read_csv : Read a comma-separated values (csv) file into DataFrame. read_fwf : Read a table of fixed-width formatted lines into DataFrame. Examples -------- >>> pd.{func_name}('data.csv') # doctest: +SKIP cCs^d|d›d|d›�}|dk rZt|ƒrBt|ƒ|kr8t|ƒ‚t|ƒ}nt|ƒrR||ksZt|ƒ‚|S)aÀ Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Parameter name (used for error reporting) val : int or float The value to check min_val : int Minimum allowed value (val < min_val will result in a ValueError) ú'Úsz' must be an integer >=ÚdN)r#ÚintÚ ValueErrorr$)ÚnameÚvalZmin_valÚmsg©rFú8/tmp/pip-target-zr53vnty/lib/python/pandas/io/parsers.pyÚvalidate_integerŠs  rHcCsH|dk rDt|ƒtt|ƒƒkr$tdƒ‚t|dd�sDt|tjƒsDtdƒ‚dS)aZ Raise ValueError if the `names` parameter contains duplicates or has an invalid data type. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Raises ------ ValueError If names are not unique or are not ordered (e.g. set). Nz Duplicate names are not allowed.F)Z allow_setsz&Names should be an ordered collection.)ÚlenÚsetrBr&Ú isinstancerÚKeysView©ÚnamesrFrFrGÚ_validate_names§s ÿ ÿrO)Úfilepath_or_bufferc Cs | dd¡dk r&t|dtƒr&d|d<| dd¡}td| dd¡dƒ}| d d¡}t| d d¡ƒt|f|Ž}|sv|rz|S|�| |¡W5QR£SQRXdS) zGeneric reader of line files.Ú date_parserNÚ parse_datesTÚiteratorFÚ chunksizeéÚnrowsrN)ÚgetrKÚboolrHrOÚTextFileReaderÚread)rPÚkwdsrSrTrVÚparserrFrFrGÚ_read¿s   r]ú"TFÚinferÚ.)%Ú delimiterÚ escapecharÚ quotecharÚquotingÚ doublequoteÚskipinitialspaceÚlineterminatorÚheaderÚ index_colrNÚprefixÚskiprowsÚ skipfooterrVÚ na_valuesÚkeep_default_naÚ true_valuesÚ false_valuesÚ convertersÚdtypeÚ cache_datesÚ thousandsÚcommentÚdecimalrRÚ keep_date_colÚdayfirstrQÚusecolsrTÚverboseÚencodingÚsqueezeÚ compressionÚmangle_dupe_colsÚinfer_datetime_formatÚskip_blank_lines)Údelim_whitespaceÚ na_filterÚ low_memoryÚ memory_mapÚerror_bad_linesÚwarn_bad_linesÚfloat_precisionéd)ÚcolspecsÚ infer_nrowsÚwidthsrlrƒr‡Ú_deprecated_defaultsÚ_deprecated_argsÚread_csvz8Read a comma-separated values (csv) file into DataFrame.z','Ústorage_options)Ú func_nameÚsummaryZ _default_sepr�)rPrvr�c24Cs>tƒ}2|2d=|2d=t|*||-| |ddid�}3|2 |3¡t||2ƒS)NrPÚsepraú,©Údefaults©ÚlocalsÚ_refine_defaults_readÚupdater])4rPr’rarhrNriryr|rjr~rrÚenginerqrorprfrkrlrVrmrnr‚rzr€rRrrwrQrxrsrSrTr}rtrvrgrcrdrerbrur{Údialectr…r†r�rƒr„r‡r�r[Ú kwds_defaultsrFrFrGrŽsDÿ Ú read_tablez+Read general delimited file into DataFrame.z'\\t' (tab-stop))rPrvc13Cs>tƒ}1|1d=|1d=t|*||-| |ddid�}2|1 |2¡t||1ƒS)NrPr’raú r”r–)3rPr’rarhrNriryr|rjr~rrršrqrorprfrkrlrVrmrnr‚rzr€rRrrwrQrxrsrSrTr}rtrvrgrcrdrerbrur{r›r…r†r�rƒr„r‡r[rœrFrFrGr�esCÿ cKsŠ|dkr|dkrtdƒ‚n|dkr2|dk r2tdƒ‚|dk rhgd}}|D]}| |||f¡||7}qH||d<||d<d|d <t||ƒS) aW Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the `online docs for IO Tools `_. Parameters ---------- filepath_or_buffer : str, path object or file-like object Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. A local file could be: ``file://localhost/path/to/table.csv``. If you want to pass in a path object, pandas accepts any ``os.PathLike``. By file-like object, we refer to objects with a ``read()`` method, such as a file handle (e.g. via builtin ``open`` function) or ``StringIO``. colspecs : list of tuple (int, int) or 'infer'. optional A list of tuples giving the extents of the fixed-width fields of each line as half-open intervals (i.e., [from, to[ ). String value 'infer' can be used to instruct the parser to try detecting the column specifications from the first 100 rows of the data which are not being skipped via skiprows (default='infer'). widths : list of int, optional A list of field widths which can be used instead of 'colspecs' if the intervals are contiguous. infer_nrows : int, default 100 The number of rows to consider when letting the parser determine the `colspecs`. .. versionadded:: 0.24.0 **kwds : optional Optional keyword arguments can be passed to ``TextFileReader``. Returns ------- DataFrame or TextParser A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes. See Also -------- DataFrame.to_csv : Write DataFrame to a comma-separated values (csv) file. read_csv : Read a comma-separated values (csv) file into DataFrame. Examples -------- >>> pd.read_fwf('data.csv') # doctest: +SKIP Nz&Must specify either colspecs or widths)Nr_z4You must specify only one of 'widths' and 'colspecs'rr‰rŠú python-fwfrš)rBÚappendr])rPr‰r‹rŠr[ÚcolÚwrFrFrGÚread_fwf´s?   r£c@sxeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ddd„Z dd„Z ddd„Z ddd„Z dd„Zdd„ZdS) rYzF Passed dialect overrides any of the related parser options NcKs||_|dk rd}nd}d}||_| d|¡|_t|ƒt|ƒ}|dk rRt||ƒ}| dd¡dkr|| d¡dkrtdnd|d<||_d|_|  |¡}| d d¡|d <|  d d¡|_ |  d d¡|_ |  d d¡|_ | ||¡| ||¡\|_|_d |k�r|d |jd <| |j¡|_dS)NTÚpythonFÚengine_specifiedrhr_rNrr�rTrVr|Úhas_index_names)ÚfršrWÚ_engine_specifiedÚ_validate_skipfooterÚ_extract_dialectÚ_merge_with_dialect_propertiesÚ orig_optionsÚ_currowÚ_get_options_with_defaultsÚpoprTrVr|Ú_check_file_or_bufferÚ_clean_optionsÚoptionsÚ _make_engineÚ_engine)Úselfr§ršr[r¥r›r²rFrFrGÚ__init__ s2    zTextFileReader.__init__cCs|j ¡dS©N)r´Úclose©rµrFrFrGr¸5szTextFileReader.closecCsþ|j}i}t ¡D]2\}}| ||¡}|dkr<|s} |�ræ|| t| k�ræt d|›dt| ƒ›d�ƒ‚|| =�q°|�rtjd|›d�tdd�|d} |d} |d} |d}|d}t|d ƒtD]N} t| }t| }| | |¡|k�rŠd!| ›d"�}tj|td#d�n||| <�qF| d k�r¨t d$ƒ‚t| ƒ�rÌt| tttjfƒ�sÌ| g} | |d<| dk �ræt| ƒn| } | dk �rt| tƒ�std%t| ƒj ›�ƒ‚ni} |d&}t!||ƒ\}}|dk�rtt"|ƒ�rPtt#|ƒƒ}|dk�rbt$ƒ}nt%|ƒ�stt$|ƒ}| |d<| |d<||d<||d'<||d<||fS)(Nrºrlrz*the 'c' engine does not support skipfooterr¤rar�zDthe 'c' engine does not support sep=None with delim_whitespace=FalserUz\s+T)r¤rŸzxthe 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex)zutf-8Fzthe separator encoded in zF is > 1 char long, and the 'c' engine does not support such separatorsrcézxord(quotechar) > 127, meaning the quotechar is larger than one byte, and the 'c' engine does not support such quotecharsz,Falling back to the 'python' engine because z, but this causes z= to be ignored as it is not supported by the 'python' engine.z;; you can avoid this warning by specifying engine='python'.é©Ú stacklevelrirNrqrmrkrhr»zH argument has been deprecated and will be removed in a future version. éz)The value of index_col couldn't be 'True'z8Type converters must be a dict or subclass, input was a rnÚ na_fvalues)&ÚcopyrIÚsysÚgetfilesystemencodingÚencodeÚUnicodeDecodeErrorrKÚstrÚbytesÚordr¨rBÚ_c_unsupportedr¿r¾rÀÚwarningsÚwarnrr:r�rŒrWÚ FutureWarningÚ _is_index_colÚlistÚtupleÚnpÚndarrayÚdictÚ TypeErrorÚtypeÚ__name__Ú_clean_na_valuesr$ÚrangerJÚcallable)rµr²ršÚresultZfallback_reasonr’r�Z encodeabler{rcÚargrirNrqrmrkÚparser_defaultZ depr_defaultrErnrÌrFrFrGr±lsÖ  ÿÿ     ÿ ÿ þýÿ   ÿ  ù   ÿ     ÿ     zTextFileReader._clean_optionscCs.z | ¡WStk r(| ¡‚YnXdSr·)Ú get_chunkÚ StopIterationr¸r¹rFrFrGrÅs  zTextFileReader.__next__rºcCsBtttdœ}||kr.td|›d| ¡›d�ƒ‚|||jf|jŽS)N)rºr¤rŸzUnknown engine: z (valid options are ú))ÚCParserWrapperÚ PythonParserÚFixedWidthFieldParserrBÚkeysr§r²)rµršÚmappingrFrFrGr³sýÿzTextFileReader._make_enginecCs t|ƒ‚dSr·)rr¹rFrFrGÚ_failover_to_pythonsz"TextFileReader._failover_to_pythoncCs¤td|ƒ}|j |¡\}}}|dkrV|rPttt| ¡ƒƒƒ}t|j|j|ƒ}q^d}nt|ƒ}t |||d�}|j|7_|j r t|j ƒdkr ||j d  ¡S|S)NrVr)ÚcolumnsÚindexrU) rHr´rZrIÚnextÚiterÚvaluesr3r­r0r|rñrÍ)rµrVròrñÚcol_dictÚnew_rowsZdfrFrFrGrZs zTextFileReader.readcCsF|dkr|j}|jdk r:|j|jkr(t‚t||j|jƒ}|j|d�S)N)rV)rTrVr­réÚminrZ©rµÚsizerFrFrGrè5s  zTextFileReader.get_chunkcCs|Sr·rFr¹rFrFrGÚ __enter__>szTextFileReader.__enter__cCs | ¡dSr·)r¸)rµÚexc_typeÚ exc_valueÚ tracebackrFrFrGÚ__exit__AszTextFileReader.__exit__)N)rº)N)N)ráÚ __module__Ú __qualname__Ú__doc__r¶r¸r®r°r±rÅr³rðrZrèrûrÿrFrFrFrGrYs ))    rYcCs|dk o|dk S)NFrF©r¡rFrFrGrÙEsrÙ©rics@ˆdkstˆtƒrg‰t|ƒo>t|tƒ o>t‡fdd„|DƒƒS)a¨ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex index_col : None, bool or list, optional Column or columns to use as the (possibly hierarchical) index Returns ------- boolean : Whether or not columns could become a MultiIndex Nc3s$|]}|tˆƒkrt|tƒVqdSr·)rÚrKrÛ©Ú.0rºrrFrGÚ as z,_is_potential_multi_index..)rKrXrIr2Úall)rñrirFrrGÚ_is_potential_multi_indexIs ÿýr cs"tˆƒr‡fdd„t|ƒDƒSˆS)zó Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. csh|]\}}ˆ|ƒr|’qSrFrF©rÚirC©ryrFrGÚ nsz$_evaluate_usecols..)räÚ enumerate)ryrNrFr rGÚ_evaluate_usecolsesrcs0‡fdd„|Dƒ}t|ƒdkr,td|›�ƒ‚|S)a% Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. names : iterable of names The column names to check against. Returns ------- usecols : iterable of usecols The `usecols` parameter if the validation succeeds. Raises ------ ValueError : Columns were missing. Error message will list them. csg|]}|ˆkr|‘qSrFrFrrMrFrGÚ ˆsz+_validate_usecols_names..rz>Usecols do not match columns, columns expected but not found: )rIrB)ryrNÚmissingrFrMrGÚ_validate_usecols_namesrs  ÿrcCs$t|ƒstdƒ‚|dkr tdƒ‚|S)að Validate the 'skipfooter' parameter. Checks whether 'skipfooter' is a non-negative integer. Raises a ValueError if that is not the case. Parameters ---------- skipfooter : non-negative integer The number of rows to skip at the end of the file. Returns ------- validated_skipfooter : non-negative integer The original input if the validation succeeds. Raises ------ ValueError : 'skipfooter' was not a non-negative integer. zskipfooter must be an integerrzskipfooter cannot be negative)r$rB)rlrFrFrGÚ_validate_skipfooter_arg‘s rcCsbd}|dk rZt|ƒr|dfSt|ƒs,t|ƒ‚tj|dd�}|dkrJt|ƒ‚t|ƒ}||fS|dfS)a+ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- usecols : list-like, callable, or None List of columns to use when parsing or a callable that can be used to filter a list of table columns. Returns ------- usecols_tuple : tuple A tuple of (verified_usecols, usecols_dtype). 'verified_usecols' is either a set if an array-like is passed in or 'usecols' if a callable or None is passed in. 'usecols_dtype` is the inferred dtype of 'usecols' if an array-like is passed in or None if a callable or None is passed in. z['usecols' must either be list-like of all strings, all unicode, all integers or a callable.NF)Úskipna)ÚemptyÚintegerÚstring)rär&rBÚlibZ infer_dtyperJ)ryrEÚ usecols_dtyperFrFrGÚ_validate_usecols_arg¯sÿrcCsBd}|dk r>t|ƒr(t |¡s>t|ƒ‚nt|ttfƒs>t|ƒ‚|S)z„ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. zSOnly booleans, lists, and dictionaries are accepted for the 'parse_dates' parameterN)r(rZis_boolrßrKrÚrÞ)rRrErFrFrGÚ_validate_parse_dates_argásÿ  rc@sÌeZdZdd„Zeeeefddœdd„Ze eddœdd „Z d d „Z e d d „ƒZ dd„Zd)dd„Zdd„Zd*dd„Zd+dd„ZdZdd„Zdd„Zd,edœdd „Zd-d!d"„Zd.d#d$„Zd%d&„Zd'd(„ZdS)/Ú ParserBasecCs@| d¡|_d|_| dd¡|_| dd¡|_tƒ|_d|_d|_ t | dd¡ƒ|_ | dd¡|_ | dd¡|_ | dd¡|_| d ¡|_| d ¡|_| d d¡|_| d d ¡|_| d¡|_| d¡|_| dd ¡|_| dd¡|_| dd ¡|_t|j |j |j|jd�|_| d¡|_t|jtttjfƒ�rÞt t!t"|jƒƒ�sJt#dƒ‚t$dd„|jDƒƒ�rht#dƒ‚| d¡�r|t#dƒ‚| d¡�r�t#dƒ‚|jdk �r*t|jtttjfƒ}|�rÈt t!t"|jƒƒ�s*t"|jƒ�s*t#dƒ‚nL|jdk �r*|jdk �rt#dƒ‚n*t"|jƒ�st#dƒ‚n|jdk�r*t#dƒ‚d|_%d |_&d|_'dS) NrNrjrirRFrQrxrwrmrÌr‚rnTrorpr~rrs)rQrxrrsrhz*header must be integer or list of integerscss|]}|dkVqdS©rNrF©rr rFrFrGrsz&ParserBase.__init__..z8cannot specify multi-index header with negative integersryz;cannot specify usecols when specifying a multi-index headerz9cannot specify names when specifying a multi-index headerzLindex_col must only contain row numbers when specifying a multi-index headerz;Argument prefix must be None if argument header is not NonerzUPassing negative integer to header is invalid. For no header, use header=None instead)(rWrNÚ orig_namesr¯rjrirJÚ unnamed_colsÚ index_namesÚ col_namesrrRrQrxrwrmrÌr‚rnrorpr~rrsÚ_make_date_converterÚ _date_convrhrKrÚrÛrÜrÝrÚmapr$rBÚanyÚ_name_processedÚ _first_chunkÚhandles)rµr[Z is_sequencerFrFrGr¶øs†     ü ÿ ÿ ÿ ÿþýÿ  ÿ   ÿzParserBase.__init__N)Úsrcr[Úreturnc Cs:t|d| dd¡| dd¡| dd¡| dd¡d�|_dS) za Let the readers open IOHanldes after they are done with their potential raises. Úrr{Nr}r„Fr�)r{r}r„r�)r9rWr))rµr*r[rFrFrGÚ _open_handlesNs    úzParserBase._open_handles)rñr+csxt|jƒrtj|j ¡Ž}n(t|jƒr@tj dd„|jDƒ¡}ng}d t‡fdd„|Dƒƒ¡}|rtt d|›d�ƒ‚dS) ao Check if parse_dates are in columns. If user has provided names for parse_dates, check if those columns are available. Parameters ---------- columns : list List of names of the dataframe. Raises ------ ValueError If column to parse_date is not in dataframe. css |]}t|ƒr|n|gVqdSr·)r&©rr¡rFrFrGrvsz.z, cs"h|]}t|tƒr|ˆkr|’qSrF©rKrÒr.©rñrFrGr s þz.z+Missing column provided to 'parse_dates': 'r>N) rrRÚ itertoolsÚchainrõr&Ú from_iterableÚjoinÚsortedrB)rµrñZ cols_neededZ missing_colsrFr0rGÚ_validate_parse_dates_presence[s$   ÿ  þÿÿ  ÿz)ParserBase._validate_parse_dates_presencecCs|jdk r|j ¡dSr·)r)r¸r¹rFrFrGr¸‹s zParserBase.closecCs6t|jtƒp4t|jtƒo4t|jƒdko4t|jdtƒS©Nr)rKrRrÞrÚrIr¹rFrFrGÚ_has_complex_date_col�s    ÿýz ParserBase._has_complex_date_colcCs|t|jtƒr|jS|jdk r(|j|}nd}|j|}t|jƒr\||jkpZ|dk oZ||jkS||jkpv|dk ov||jkSdSr·)rKrRrXr!rir()rµr rCÚjrFrFrGÚ_should_parse_dates—s      ÿ ÿzParserBase._should_parse_datesFc s:t|ƒdkr|d|||fSˆj}|dkr.g}t|tttjfƒsF|g}t|ƒ‰| d¡}t |ˆjˆj ƒ\}}}t|dƒ‰‡‡fdd„‰tt ‡fdd„|DƒŽƒ}||}t t|dƒƒD]B‰t ‡‡fd d„|Dƒƒrºd  d d„ˆjDƒ¡}td |›d �ƒ‚qºt|ƒ�r‡fdd„|Dƒ}ndgt|ƒ}d}||||fS)z‚ extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers rËrNéÿÿÿÿcst‡‡fdd„tˆƒDƒƒS)Nc3s|]}|ˆkrˆ|VqdSr·rFr)r,ÚsicrFrGrÉszMParserBase._extract_multi_indexer_columns..extract..)rÛrã©r,)Ú field_countr<r=rGÚextractÈsz:ParserBase._extract_multi_indexer_columns..extractc3s|]}ˆ|ƒVqdSr·rF©rr,)r?rFrGrËsz.c3s |]}t|ˆƒˆjkVqdSr·)rr r.)ÚnrµrFrGrÑsr“css|]}t|ƒVqdSr·©rÒ©rÚxrFrFrGrÒszPassed header=[z3] are too many rows for this multi_index of columnscs2g|]*}|ddk r*|dˆjkr*|dnd‘qSr)r r@r¹rFrGrÚsÿz=ParserBase._extract_multi_indexer_columns..T)rIrirKrÚrÛrÜrÝrJr¯Ú_clean_index_namesr Úziprãrr4rhr) rµrhr!r"Ú passed_namesÚicrNrirñrF)r?r>rArµr<rGÚ_extract_multi_indexer_columnsªs>  ÿ   ÿ  þz)ParserBase._extract_multi_indexer_columnscCs¦|jr¢t|ƒ}ttƒ}t||jƒ}t|ƒD]v\}}||}|dkrŒ|d||<|rt|dd…|d›d|›�f}n|›d|›�}||}q:|||<|d||<q*|S)NrrUr;r`)r~rÚrrAr rir)rµrNÚcountsZis_potential_mir r¡Ú cur_countrFrFrGÚ_maybe_dedup_namesås  " zParserBase._maybe_dedup_namescCst|ƒrtj||d�}|S)NrM)r r2Ú from_tuples)rµrñr"rFrFrGÚ_maybe_make_multi_index_columnssz*ParserBase._maybe_make_multi_index_columnscCsºt|jƒr|jsd}nh|js4| ||¡}| |¡}nJ|jr~|jsdtt|ƒ|j|jƒ\|_ }|_d|_|  ||¡}|j|dd�}|r¤t |ƒt |ƒ}|  |d|…¡}|  ||j¡}||fS)NTF©Útry_parse_dates)rÙrir8Ú_get_simple_indexÚ _agg_indexr'rErÚr r!Ú_get_complex_date_indexrIZ set_namesrNr")rµÚdataÚalldatarñÚ indexnamerowròÚ_ZcoffsetrFrFrGÚ _make_index s(  ÿ zParserBase._make_indexcCsldd„}g}g}|jD]$}||ƒ}| |¡| ||¡qt|dd�D]}| |¡|jsH| |¡qH|S)NcSs"t|tƒs|Std|›d�ƒ‚dS)NzIndex z invalid)rKrÒrBrrFrFrGÚix(s z(ParserBase._get_simple_index..ixT©Úreverse)rir r5r¯Ú_implicit_index)rµrTrñrYÚ to_removeròÚidxr rFrFrGrQ's    zParserBase._get_simple_indexc sj‡fdd„}g}g}|jD]$}||ƒ}| |¡| ||¡qt|dd�D]}| |¡ˆ |¡qL|S)NcsLt|tƒr|Sˆdkr&td|›d�ƒ‚tˆƒD]\}}||kr.|Sq.dS)Nz Must supply column order to use z as index)rKrÒrBr)Zicolr rº©r"rFrGÚ _get_name>s z5ParserBase._get_complex_date_index.._get_nameTrZ)rir r5r¯Úremove) rµrTr"r`r]ròr^rCrºrFr_rGrS=s     z"ParserBase._get_complex_date_indexT©r+c Cs¶g}t|ƒD]”\}}|r,| |¡r,| |¡}|jr@|j}|j}n tƒ}tƒ}t|jtƒr‚|j |}|dk r‚t ||j|j|j ƒ\}}|  |||B¡\}} |  |¡q |j } t|| ƒ}|Sr·)rr:r$r‚rmrÌrJrKrÞr!Ú_get_na_valuesrnÚ _infer_typesr r4) rµròrPÚarraysr ZarrÚ col_na_valuesÚcol_na_fvaluesÚcol_namerWrNrFrFrGrRXs.   ÿ  zParserBase._agg_indexc Csài}| ¡D�]Ì\}} |dkr"dn | |d¡} t|tƒrF| |d¡} n|} |jrft||||jƒ\} } ntƒtƒ} } | dk �r| dk ržtj d|›d�t dd�zt   | | ¡} Wn:t k rèt | t|ƒ¡ tj¡}t  | | |¡} YnX|j| t| ƒ| Bdd�\}}n®t| ƒ}|�pt| ƒ}| �o&| }| | t| ƒ| B|¡\}}| �r¶t|| ƒ�r`t| ƒ�r¶|�s¨|dk�r¨zt| ƒ�rŠt d|›�ƒ‚Wnttfk �r¦YnX| || |¡}|||<|r |r td |›d |›�ƒq |S) Nz5Both a converter and dtype were specified for column z" - only the converter will be usedérÉF)Ú try_num_boolrz$Bool column has NA values in column zFilled z NA values in column )r½rWrKrÞr‚rcrnrJrÖr×rrZ map_inferrBr-ÚisinrÚÚviewrÜZuint8Zmap_infer_maskrdr!r)r rÚAttributeErrorrßÚ _cast_typesÚprint)rµÚdctrmrÌrzrqZdtypesrårºrõZconv_fÚ cast_typerfrgÚmaskZcvalsÚna_countZis_eaZis_str_or_ea_dtyperjrFrFrGÚ_convert_to_ndarraysxsr ÿ   ú  ÿ   ÿÿþ ÿzParserBase._convert_to_ndarraysc Csd}t|jjtjtjfƒrft |t|ƒ¡}|  ¡}|dkr^t |ƒrN|  tj ¡}t  ||tj¡||fS|rÀt|jƒrÀzt ||d¡}Wn*ttfk r°|}t ||d¡}YqÞXt|ƒ  ¡}n|}|jtjkrÞt ||d¡}|jtjk�r |�r tjt |¡|j|jd�}||fS)aU Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolean Returns ------- converted : ndarray na_count : int rF)rorp)Ú issubclassrrràrÜÚnumberZbool_r-rkrÚÚsumr%ZastypeÚfloat64ZputmaskÚnanr'rZmaybe_convert_numericrBrßÚparsersZsanitize_objectsr,Zobject_ÚlibopsZmaybe_convert_boolZasarrayrorp)rµrõrmrjrsrrrårFrFrGrdÁs4  ýzParserBase._infer_typesc Cst|ƒr^t|tƒo|jdk }t|ƒs2|s2t|tƒ}t|ƒ ¡  ¡}t j ||  |¡||j d�}n°t|ƒr¾t|ƒ}| ¡}z|j||d�WStk rº}ztd|›d�ƒ|‚W5d}~XYnXnPzt||ddd�}Wn:tk �r }ztd|›d |›�ƒ|‚W5d}~XYnX|S) aF Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting Returns ------- converted : ndarray N)ro©rrzExtension Array: zO must implement _from_sequence_of_strings in order to be used in parser methodsT)rÍrzUnable to convert column z to type )rrKr+Ú categoriesr'rrÒr1ÚuniqueZdropnar/Z_from_inferred_categoriesZ get_indexerror!r*Zconstruct_array_typeZ_from_sequence_of_stringsÚNotImplementedErrorrB)rµrõrqÚcolumnZ known_catsZcatsZ array_typeÚerrrFrFrGrnôsB þ  ÿ ÿýÿþzParserBase._cast_typesc Cs6|jdk r.t||j|j|j|j||jd�\}}||fS)N)rw)rRÚ_process_date_conversionr$rir!rw)rµrNrTrFrFrGÚ_do_date_conversions+s ù zParserBase._do_date_conversions)F)N)F)T)FNN)T)rárrr¶rrrÒrr-r r6r¸Úpropertyr8r:rIrLrNrXr\rQrSr1rRrtrdrnrƒrFrFrFrGr÷s.V 0 ÿ ;  !ÿ I 37rcsdeZdZedœdd„Zddœ‡fdd„ Zdd „Zd d „Zdd d „Zdd„Z dd„Z ddd„Z ‡Z S)rë)r*c sä|ˆ_| ¡}t ˆ|¡ˆjdk |d<t|dƒ\ˆ_ˆ_ˆj|d<ˆ ||¡ˆj dk s`t ‚dD]}|  |d¡qdˆj j ršt ˆj jdƒršˆj jjˆj _ztjˆj jf|Žˆ_Wn tk rÒˆj  ¡‚YnXˆjjˆ_ˆjdk}ˆjjdkrüdˆ_nLtˆjjƒdk�r6ˆ ˆjjˆjˆj|¡\ˆ_ˆ_ˆ_}ntˆjjdƒˆ_ˆjdk�rŒˆj�rz‡fdd „tˆjjƒDƒˆ_nttˆjjƒƒˆ_ˆjdd…ˆ_ ˆj�r:t!ˆjˆj ƒ‰ˆj dk �sÂt ‚ˆjd k�rìt"ˆƒ #ˆj ¡�sìt$ˆˆj ƒtˆjƒtˆƒk�r‡fd d „t%ˆjƒDƒˆ_tˆjƒtˆƒk�r:t$ˆˆjƒˆ &ˆj¡ˆ '¡ˆjˆ_ ˆj(�sÒˆjj)dk�r¬t*ˆjƒ�r¬d ˆ_+t,ˆjˆjˆjƒ\}ˆ_ˆ_ˆjdk�r¬|ˆ_ˆjjdk�rÒ|�sÒdgtˆjƒˆ_ˆjj)dkˆ_-dS) NFZallow_leading_colsry)r�r{r„r}ÚmmaprUrcsg|]}ˆj›|›�‘qSrF©rjrr¹rFrGr„sz+CParserWrapper.__init__..rcs$g|]\}}|ˆks|ˆkr|‘qSrFrF©rr rAr rFrGr sþT).r[rÍrr¶rirryrr-r)ÚAssertionErrorr¯Zis_mmaprÆÚhandler…rzZ TextReaderÚ_readerÚ Exceptionr¸r rNrhrIrIr!r"rÚrjrãZ table_widthrrrJÚissubsetrrr6Ú_set_noconvert_columnsr8Ú leading_colsrÙr'rEr\)rµr*r[ÚkeyrGr!rF)rµryrGr¶=s’       ÿûü    ÿ  ÿ  þ  ÿ ÿzCParserWrapper.__init__Nrbcs2tƒ ¡z|j ¡Wntk r,YnXdSr·)Úsuperr¸rŠrBr¹©Ú __class__rFrGr¸Ãs  zCParserWrapper.closecs&ˆj‰ˆjdkr$tˆjƒ‰ˆ ¡n(tˆjƒs8ˆjdkrHˆjdd…‰nd‰‡‡‡fdd„}tˆjtƒrœˆjD]*}t|tƒr�|D] }||ƒq€qn||ƒqnn†tˆjt ƒràˆj  ¡D]*}t|tƒrÔ|D] }||ƒqÄq²||ƒq²nBˆj�r"tˆj tƒ�r ˆj D] }||ƒqünˆj dk �r"|ˆj ƒdS)z¹ Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions. r)rNNcsFˆdk rt|ƒrˆ|}t|ƒs6ˆdk s,t‚ˆ |¡}ˆj |¡dSr·)r$rˆròrŠZ set_noconvert©rD©rNrµryrFrGÚ_setås   z3CParserWrapper._set_noconvert_columns.._set) rrrÚryÚsorträrNrKrRrÞrõri©rµr•rDÚkrFr”rGr�Ìs4               z%CParserWrapper._set_noconvert_columnscCs|j t|ƒ¡dSr·)rŠÚset_error_bad_linesrA)rµÚstatusrFrFrGr™sz"CParserWrapper.set_error_bad_linesc s(z|j |¡}Wnžtk r®|jr d|_| |j¡}t||j|j|j   d¡d�\}‰}|  ˆ|j ¡‰|j dk r|| ˆ¡‰‡fdd„| ¡Dƒ}|ˆ|fYS| ¡‚YnXd|_|j}|jj�r†|jrÔtdƒ‚g}t|jjƒD]F}|jdk�r| |¡}n| |j|¡}|j||dd�}| |¡qät|ƒ}|j dk �rJ| |¡}| |¡}t| ¡ƒ}d d„t||ƒDƒ}| ||¡\}}nŠt| ¡ƒ}|jdk �s¢t‚t|jƒ}| |¡}|j dk �rÌ| |¡}d d „|Dƒ} d d„t||ƒDƒ}| ||¡\}}| || |¡\}}|  ||j ¡}|||fS) NFrrr|csi|]\}}|ˆkr||“qSrFrF©rr˜Úvr0rFrGÚ sz'CParserWrapper.read..z file structure not yet supportedTrOcSsi|]\}\}}||“qSrFrF©rr˜r rœrFrFrGr�Cs cSsg|] }|d‘qS)rUrFrCrFrFrGrVsz'CParserWrapper.read..cSsi|]\}\}}||“qSrFrFržrFrFrGr�Xs ) rŠrZrér(rLrÚ_get_empty_metarir!r[rWrNr"ryÚ_filter_usecolsr½r¸rNrŽr8rrãr¯Ú_maybe_parse_datesr r4r5rFrƒrˆrÚrX) rµrVrTrNròrörer rõrUrFr0rGrZ sd  ü                zCParserWrapper.readcs>t|j|ƒ‰ˆdk r:t|ƒtˆƒkr:‡fdd„t|ƒDƒ}|S)Ncs$g|]\}}|ˆks|ˆkr|‘qSrFrFr r rFrGrfsz2CParserWrapper._filter_usecols..)rryrIr)rµrNrFr rGr bs   ÿzCParserWrapper._filter_usecolscCsJt|jjdƒ}d}|jjdkrB|jdk rBt||j|jƒ\}}|_||fSr7)rÚrŠrhrŽrirEr )rµrNZ idx_namesrFrFrGÚ_get_index_namesksÿ zCParserWrapper._get_index_namesTcCs|r| |¡r| |¡}|Sr·)r:r$)rµrõròrPrFrFrGr¡vs z!CParserWrapper._maybe_parse_dates)N)T) rárrrr¶r¸r�r™rZr r¢r¡Ú __classcell__rFrFr‘rGrë<s < W  rëcOsd|d<t||ŽS)av Converts lists of lists/tuples into DataFrames with proper type inference and optional (e.g. string to datetime) conversion. Also enables iterating lazily over chunks of large files Parameters ---------- data : file-like object or list delimiter : separator character to use dialect : str or csv.Dialect instance, optional Ignored if delimiter is longer than 1 character names : sequence, default header : int, default 0 Row to use to parse column labels. Defaults to the first row. Prior rows will be discarded index_col : int or list, optional Column or columns to use as the (possibly hierarchical) index has_index_names: bool, default False True if the cols defined in index_col have an index name and are not in the header. na_values : scalar, str, list-like, or dict, optional Additional strings to recognize as NA/NaN. keep_default_na : bool, default True thousands : str, optional Thousands separator comment : str, optional Comment out remainder of line parse_dates : bool, default False keep_date_col : bool, default False date_parser : function, optional skiprows : list of integers Row numbers to skip skipfooter : int Number of line at bottom of file to skip converters : dict, optional Dict of functions for converting values in certain columns. Keys can either be integers or column labels, values are functions that take one input argument, the cell (not column) content, and return the transformed content. encoding : str, optional Encoding to use for UTF when reading/writing (ex. 'utf-8') squeeze : bool, default False returns Series if only one column. infer_datetime_format: bool, default False If True and `parse_dates` is True for a column, try to infer the datetime format based on the first datetime string. If the format can be inferred, there often will be a large parsing speed-up. float_precision : str, optional Specifies which converter the C engine should use for floating-point values. The options are `None` or `high` for the ordinary converter, `legacy` for the original lower precision pandas converter, and `round_trip` for the round-trip converter. .. versionchanged:: 1.2 r¤rš)rY)Úargsr[rFrFrGÚ TextParser|s8r¥rbcCstdd„|DƒƒS)Ncss"|]}|dks|dkrdVqdS)ÚNrUrF)rrœrFrFrGr¹sz#count_empty_vals..)rw)ÚvalsrFrFrGÚcount_empty_vals¸sr¨c@säeZdZeeefdœdd„Zdd„Zdd„Zd4d d „Z d d „Z d5d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-Zd.d/„Zd0d1„Zd6d2d3„ZdS)7rì)r§c s.t ˆ|¡dˆ_gˆ_dˆ_dˆ_|dˆ_tˆjƒrBˆjˆ_n‡fdd„ˆ_t |dƒˆ_ |dˆ_ |dˆ_ t ˆj tƒrŠtˆj ƒˆ_ |d ˆ_|d ˆ_|d ˆ_|d ˆ_|d ˆ_t|dƒ\ˆ_}|dˆ_|dˆ_|dˆ_|dpödˆ_dˆ_d|k�r|dˆ_|dˆ_|dˆ_|dˆ_|dˆ_|dˆ_|dˆ_ t |t!ƒ�rnt"t#t|ƒˆ_njˆ $||¡ˆj%dk �sŠt&‚t'ˆj%j(dƒ�sžt&‚zˆ )ˆj%j(¡Wn&t*j+t,fk �rÖˆ -¡‚YnXdˆ_.zˆ /¡\ˆ_0ˆ_1ˆ_2Wn$t3t4fk �rˆ -¡‚YnXt5ˆj0ƒdk�r\ˆ 6ˆj0ˆj7ˆj8¡\ˆ_0ˆ_7ˆ_8}t5ˆj0ƒˆ_1n ˆj0dˆ_0t!ˆj0ƒˆ_9ˆj:�sªˆ ;ˆj0¡\}ˆ_9ˆ_0dˆ_<ˆj7dk�rª|ˆ_7ˆ =ˆj0¡ˆj>�rʈ ?¡ˆ_@ndˆ_@t5ˆjƒdk�rèt4dƒ‚ˆjdk�r tA Bdˆj›d �¡ˆ_CntA Bdˆj›d!ˆj›d �¡ˆ_CdS)"zN Workhorse function for processing nested list into DataFrame Nrrkcs |ˆjkSr·)rkr“r¹rFrGÚÍóz'PythonParser.__init__..rlrarcrbrerfrgrdryr€r†r…rNFr¦rzrqrrrtrvruÚreadlinerUTz'Only length-1 decimal markers supportedz[^-^0-9^z]+ú^)Drr¶rTÚbufÚposÚline_posrkräÚskipfuncrrlrarcrKrÒrbrerfrgrdrryr€r†r…Z names_passedr¦rzrqrrrtrvrurÚrr r-r)rˆrÆr‰Ú _make_readerÚcsvÚErrorrÑr¸Ú _col_indicesÚ_infer_columnsrñÚnum_original_columnsr rßrBrIrIr!r"rr8Ú_get_index_namer'r6rRÚ_set_no_thousands_columnsÚ_no_thousands_columnsÚreÚcompileÚnonnum)rµr§r[rWr!rFr¹rGr¶½s¨                          üýÿû  ÿ    zPythonParser.__init__csØtƒ‰‡‡fdd„}tˆjtƒrTˆjD]*}t|tƒrH|D] }||ƒq8q&||ƒq&n€tˆjtƒr˜ˆj ¡D]*}t|tƒrŒ|D] }||ƒq|qj||ƒqjn<ˆjrÔtˆjtƒrÀˆjD] }||ƒq°nˆjdk rÔ|ˆjƒˆS)Ncs*t|ƒrˆ |¡nˆ ˆj |¡¡dSr·)r$Úaddrñròr“©Znoconvert_columnsrµrFrGr•= s z4PythonParser._set_no_thousands_columns.._set)rJrKrRrÚrÞrõrir—rFr¾rGr¸8 s*              z&PythonParser._set_no_thousands_columnsc s4ˆj‰ˆdkstˆƒdk�rˆjr*tdƒ‚G‡fdd„dtjƒ}|}ˆdk rTˆ|_n°ˆ ¡}ˆ |gg¡d}ˆ ˆj ¡s~|s¨ˆj d7_ ˆ ¡}ˆ |gg¡d}qn|d}ˆj d7_ ˆj d7_ t  ¡  |¡}|j|_tj t|ƒ|d�}ˆj t|ƒ¡tj ˆ|dd�}n‡‡fd d „} | ƒ}|ˆ_dS) NrUz.MyDialectÚ N) rárrrarcrbrerfrdrgrFr¹rFrGÚ MyDialecte srÀr)r›T)r›Ústrictc3s@ˆ ¡}t ˆ¡}| | ¡¡VˆD]}| | ¡¡Vq&dSr·)r«rºr»ÚsplitÚstrip)ÚlineÚpat)r§r’rFrGr]Ž s  z(PythonParser._make_reader.._read)rarIrgrBr²ÚDialectr«Ú_check_commentsr°r®r¯ÚSnifferÚsniffÚreaderrr­ÚextendrÚrT) rµr§rÀZdiarÄÚlinesÚsniffedZline_rdrrÊr]rF)r§rµr’rGr±\ s6ÿ  zPythonParser._make_readerNc Csz| |¡}Wn*tk r8|jr*g}n | ¡‚YnXd|_t|jƒ}t|ƒs�| |j¡}t||j |j |j ƒ\}}}|  ||j ¡}|||fSt|dƒ}d}|jrÆ|t|ƒkrÆ|d}|dd…}| |¡} | | ¡} | |j¡}| || ¡\}} | | ¡} | | | ||¡\}}||| fS)NFrrU)Ú _get_linesrér(r¸rÚrrIrLrŸrir!rrrNr"r¨r¦Ú _rows_to_colsÚ_exclude_implicit_indexrñrƒÚ _convert_datarX) rµÚrowsÚcontentrñrNròröZcount_empty_content_valsrVrUrTrFrFrGrZŸ s>  ÿ        zPythonParser.readcCsr| |j¡}|jrZ|j}i}d}t|ƒD].\}}|||krF|d7}q0|||||<q(ndd„t||ƒDƒ}|S)NrrUcSsi|]\}}||“qSrFrFr›rFrFrGr�Ø sz8PythonParser._exclude_implicit_index..)rLrr\rirrF)rµrUrNZ excl_indicesrTÚoffsetr r¡rFrFrGrÐË s   z$PythonParser._exclude_implicit_indexcCs|dkr|j}|j|d�S)N)rÒ)rTrZrùrFrFrGrèÝ szPythonParser.get_chunkc sº‡fdd„}|ˆjƒ}tˆjtƒs*ˆj}n |ˆjƒ}i}i}tˆjtƒr˜ˆjD]F}ˆj|}ˆj|} t|tƒr„|ˆjkr„ˆj|}|||<| ||<qNn ˆj}ˆj}ˆ |||ˆj ||¡S)Ncs@i}| ¡D].\}}t|tƒr2|ˆjkr2ˆj|}|||<q |S)zconverts col numbers to names)r½rKrAr)rïÚcleanr¡rœr¹rFrGÚ_clean_mappingæ sÿþ  z2PythonParser._convert_data.._clean_mapping) rqrKrrrÞrmrÌrArrtrz) rµrTrÖZ clean_convZ clean_dtypesZclean_na_valuesZclean_na_fvaluesr¡Zna_valueZ na_fvaluerFr¹rGrÑä s8        ÿþ  úzPythonParser._convert_datac s¼ˆj}d}d}tƒ}ˆjdk �ržˆj}t|tttjfƒr`t|ƒdk}|rjt|ƒ|ddg}n d}|g}g}t |ƒD�]h\}} z ˆ  ¡} ˆj | kržˆ  ¡} qŠWn¶t k �rV} z–ˆj | krÜtd| ›dˆj d›d�ƒ| ‚|�r&| dk�r&|røˆ ¡| dgt|dƒ¡|||fWY¢*Sˆj�s8td ƒ| ‚ˆjdd…} W5d} ~ XYnXg‰g} t | ƒD]V\} }|d k�r²|�r’d | ›d |›�}n d | ›�}|  | ¡ˆ |¡n ˆ |¡�qh|�s8ˆj�r8ttƒ}t ˆƒD]V\} }||}|dk�r|d||<|›d |›�}||}�qî|ˆ| <|d||<�qÞnr|�rª| |dk�rªtˆƒ}ˆjdk �rjtˆjƒnd}t| ƒ}||k�rª|||k�rªd}dg|‰ˆjdgˆ_| ˆ¡| ‡fdd„| Dƒ¡t|ƒdkrvtˆƒ}qv|�rðˆ ¡|dk �rŠˆjdk �rt|ƒtˆjƒk�s<ˆjdk�rDt|ƒt|dƒk�rDtdƒ‚t|ƒdk�rZtdƒ‚ˆjdk �rtˆ ||¡ndˆ_t|ƒ}|g}nˆ ||d¡}�nz ˆ  ¡} Wn@t k �rê} z |�sÎtd ƒ| ‚|dd…} W5d} ~ XYnXt| ƒ}|}|�s@ˆj�r ‡fdd„t|ƒDƒg}ntt|ƒƒg}ˆ ||d¡}nrˆjdk�sZt|ƒ|k�rrˆ |g|¡}t|ƒ}n@tˆjƒ�sšt|ƒtˆjƒk�rštdƒ‚ˆ |g|¡|g}|}|||fS)NrTrUr;FzPassed header=z but only z lines in filezNo columns to parse from filer¦z Unnamed: Z_level_r`csh|] }ˆ|’qSrFrFr)Ú this_columnsrFrGr ‡ sz.PythonParser._infer_columns..zHNumber of passed names did not match number of header fields in the filez*Cannot pass names with multi-index columnscsg|]}ˆj›|›�‘qSrFr†rr¹rFrGr¶ sÿz/PythonParser._infer_columns..)rNrJrhrKrÚrÛrÜrÝrIrÚ_buffered_liner¯Ú _next_linerérBÚ _clear_bufferr rr~rrArir­r™ryrßÚ_handle_usecolsr´rjrãrä)rµrNr¶Z clear_bufferr rhZhave_mi_columnsrñÚlevelÚhrrÄr�Zthis_unnamed_colsr rºrhrJr¡rKÚlcrHZ unnamed_countZncolsrF)rµr×rGrµ sà    ÿý               ÿÿÿ    þÿ   ÿzPythonParser._infer_columnsc sÊ|jdk rÆt|jƒr"t|j|ƒ‰nŒtdd„|jDƒƒr¨t|ƒdkrJtdƒ‚g‰|jD]P}t|tƒršzˆ |  |¡¡Wq¤tk r–t |j|ƒYq¤XqTˆ |¡qTn|j‰‡fdd„|Dƒ}ˆ|_ |S)zb Sets self._col_indices usecols_key is used if there are string usecols. Ncss|]}t|tƒVqdSr·r/)rÚurFrFrGrÛ sz/PythonParser._handle_usecols..rUz4If using multiple headers, usecols must be integers.cs"g|]}‡fdd„t|ƒDƒ‘qS)csg|]\}}|ˆkr|‘qSrFrFr‡©Z col_indicesrFrGrî sz;PythonParser._handle_usecols...)r)rr€ràrFrGrí sÿz0PythonParser._handle_usecols..) ryrärr&rIrBrKrÒr ròrr´)rµrñZ usecols_keyr¡rFràrGrÛÒ s,   ÿ   þzPythonParser._handle_usecolscCs$t|jƒdkr|jdS| ¡SdS)zH Return a line from buffer, filling buffer if required. rN)rIr­rÙr¹rFrFrGrØô s zPythonParser._buffered_linecCsÒ|s|St|dtƒs|S|ds&|S|dd}|tkr>|S|d}t|ƒdkr´|d|jkr´d}|d}|dd… |¡d}|||…}t|ƒ|dkrÀ|||dd…7}n |dd…}|g|dd…S)a- Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, not the middle of it. rrUrËN)rKrÒÚ_BOMrIrcrò)rµZ first_rowZ first_eltZ first_row_bomÚstartÚquoteÚendÚnew_rowrFrFrGÚ_check_for_bomý s&    zPythonParser._check_for_bomcCs| ptdd„|DƒƒS)zô Check if a line is empty or not. Parameters ---------- line : str, array-like The line of data to check. Returns ------- boolean : Whether or not the line is empty. css|] }| VqdSr·rFrCrFrFrGr= sz.PythonParser._is_line_empty..)r)rµrÄrFrFrGÚ_is_line_empty0 s zPythonParser._is_line_emptycCs–t|jtƒr¸| |j¡r(|jd7_q zr| |j|jg¡d}|jd7_|jsv| |j|jd¡sp|rvWq¶n"|jr˜| |g¡}|r˜|d}Wq¶Wq(t k r²t ‚Yq(Xq(nª| |j¡rì|jd7_|jdk sàt ‚t |jƒq¸|j |jdd�}|jd7_|dk rì| |g¡d}|j�rL| |g¡}|�r`|d}�qbqì| |¡�sb|rì�qbqì|jdk�rx| |¡}|jd7_|j |¡|S)NrUr©Úrow_num)rKrTrÚr°r®rÇr€rçÚ_remove_empty_linesÚ IndexErrorrérˆróÚ_next_iter_linerær¯r­r )rµrÄÚretZ orig_linerFrFrGrÙ? sN  ÿÿ       zPythonParser._next_linecCs:|jrt|ƒ‚n&|jr6d|›d�}tj ||d¡dS)aÚ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message to display. row_num : The row number where the parsing error occurred. Because this row number is displayed, we 1-index, even though we 0-index internally. zSkipping line z: r¿N)r…rr†rÎÚstderrÚwrite)rµrEréÚbaserFrFrGÚ_alert_malformedu s   zPythonParser._alert_malformedc Cs˜z|jdk st‚t|jƒWStjk r’}zX|js:|jr|t|ƒ}d|ksRd|krVd}|jdkrpd}|d|7}|  ||¡WY¢dSd}~XYnXdS)aL Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- row_num : The row number of the line being parsed. Nz NULL bytezline contains NULz„NULL byte detected. This byte cannot be processed in Python's native csv library at the moment, so please pass in engine='c' insteadrz¡Error could possibly be due to parsing errors in the skipped footer rows (the skipfooter keyword is only applied after Python's csv library has parsed all rows).ú. ) rTrˆrór²r³r†r…rÒrlrñ)rµréÚerEÚreasonrFrFrGrì‰ s   ÿ ÿ  zPythonParser._next_iter_linecCs†|jdkr|Sg}|D]j}g}|D]R}t|tƒr:|j|krF| |¡q"|d| |j¡…}t|ƒdkrp| |¡qvq"| |¡q|Sr7)rurKrÒr ÚfindrI)rµrÌrírÄÚrlrDrFrFrGrDz s     zPythonParser._check_commentscCsNg}|D]@}t|ƒdks>t|ƒdkrt|dtƒr>|d ¡r| |¡q|S)a} Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- filtered_lines : array-like The same array of lines with the "empty" ones removed. rUr)rIrKrÒrÃr )rµrÌrírÄrFrFrGrêà s ÿ þ ý ý z PythonParser._remove_empty_linescCs |jdkr|S|j||jdd�S)Nr¦©rÌÚsearchÚreplace)rtÚ_search_replace_num_columns©rµrÌrFrFrGÚ_check_thousandsÝ s ÿzPythonParser._check_thousandsc Cs‚g}|D]t}g}t|ƒD]X\}}t|tƒrR||ksR|jrB||jksR|j | ¡¡r^| |¡q| | ||¡¡q| |¡q|Sr·) rrKrÒr¹r¼rørÃr rù) rµrÌrørùrírÄrör rDrFrFrGrúå s$ÿþýýü  z(PythonParser._search_replace_num_columnscCs$|jtdkr|S|j||jdd�S)Nrvr`r÷)rvr¼rúrûrFrFrGÚ_check_decimalö sÿzPythonParser._check_decimalcCs g|_dSr·)r­r¹rFrFrGrÚþ szPythonParser._clear_bufferFc CsHt|ƒ}t|ƒ}z | ¡}Wntk r4d}YnXz | ¡}Wntk rZd}YnXd}|dk rö|jdk r€t|ƒ|j}|dk röt|ƒt|ƒ|jkröttt|ƒƒƒ|_|jdd…|_t|ƒD]}|  d|¡qÈt|ƒ}t|ƒ|_|||fS|dk�r&d|_ |jdk�r tt|ƒƒ|_d}nt ||j|j ƒ\}}|_|||fS)aÐ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more columns on row 1 than row 0. If this is true, assume that row 1 lists index columns and row 0 lists normal columns. 2) Get index from the columns if it was listed. NrFrUT) rÚrÙrérirIr¶rãr­ÚreversedÚinsertr\rEr ) rµrñrrÄZ next_lineZimplicit_first_colsrºZ index_nameZcolumns_rFrFrGr· sD           ÿ zPythonParser._get_index_namecsšˆj}ˆjr|tˆjƒ7}tdd„|Dƒƒ}||k�rDˆjdk �rDˆjdk�rDˆjrZˆjnd}g}t|ƒ}t|ƒ}g}|D]Z\}} t| ƒ} | |krʈjsžˆj rÔˆj |||} |  | | f¡ˆjrÔqÖqz|  | ¡qz|D]h\} } d|›d| d›d| ›�} ˆj �r2tˆj ƒdk�r2ˆj tjk�r2d } | d | 7} ˆ | | d¡qÚttj||d �jƒ}ˆj�r–ˆj�r€‡fd d „t|ƒDƒ}n‡fdd „t|ƒDƒ}|S)Ncss|]}t|ƒVqdSr·)rI©rÚrowrFrFrGrI sz-PythonParser._rows_to_cols..Frz Expected z fields in line rUz, saw zXError could possibly be due to quotes being ignored when a multi-char delimiter is used.rò)Z min_widthcs6g|].\}}|tˆjƒks.|tˆjƒˆjkr|‘qSrF)rIrir´©rr Úar¹rFrGr| s  ÿúz.PythonParser._rows_to_cols..csg|]\}}|ˆjkr|‘qSrF)r´rr¹rFrGrˆ s þ)r¶r\rIriÚmaxryrlrr…r†r®r rardr²Ú QUOTE_NONErñrÚrZto_object_arrayÚT)rµrÓZcol_lenÚmax_lenZfootersZ bad_linesÚ iter_contentZ content_lenr ÚlZ actual_lenrérErôZzipped_contentrFr¹rGrÏC sT"    ÿÿ þ ýÿ  þ üzPythonParser._rows_to_colscs*ˆj}d}|dk rPtˆjƒ|krBˆjd|…ˆj|d…}ˆ_n|tˆjƒ8}|dk�rÞtˆjtƒrìˆjtˆjƒkrzt‚|dkržˆjˆjd…}tˆjƒ}n ˆjˆjˆj|…}ˆj|}ˆjrÚ‡fdd„t|ƒDƒ}|  |¡|ˆ_nêg}z„|dk �r8t |ƒD]&}ˆjdk �st ‚|  t ˆjƒ¡�q|  |¡n:d}ˆjˆj|dd�}|d7}|dk �r<|  |¡�q.rrUrècs$g|]\}}ˆ |ˆj¡s|‘qSrFr r r¹rFrGrË sþ)r­rIrKrTrÚr®rérkrrËrãrˆr rórìrlrÇr€rêrürý)rµrÒrÌr÷Únew_posrWrårFr¹rGrΑ sf"     þ      þ    zPythonParser._get_lines)N)N)N)rárrrrr r¶r¸r±rZrÐrèrÑrµrÛrØrærçrÙrñrìrÇrêrürúrýrÚr\r·rÏrÎrFrFrFrGrì¼s4{$C , ;4" 36)@Nrìcs‡‡‡‡fdd„}|S)Nc süˆdkrbt |¡}z tjt|ƒdˆdˆˆd� ¡WStk r^tjtj|ˆd�ˆd�YSXn–z.tjˆ|Ždˆd�}t|t j ƒrŒt dƒ‚|WSt k �röz&tjtjt |¡ˆˆd�dd�WYSt k �rðt ˆf|žŽYYSXYnXdS) NÚignore)ÚutcrxÚerrorsrÚcache)rx)r)rrz scalar parser)r\rx)r) rZconcat_date_colsÚtoolsÚ to_datetimerZto_numpyrBrPrKÚdatetimer‹r;)Ú date_colsÚstrsrå©rsrQrxrrFrGÚ converteræ sJ ú  ÿÿ ýú z'_make_date_converter..converterrF)rQrxrrsrrFrrGr#ã s'r#csЇ‡fdd„}g}i} |} t|ƒ}tƒ} |dks:t|tƒrB||fSt|tƒrÜ|D]ˆ} t| ƒr’t| tƒrv| |krv| | } || ƒr€qP||| ƒ|| <qPt|| || ƒ\} }}| |kr¼td| ›�ƒ‚|| | <| | ¡|   |¡qPnht|t ƒ�rD|  ¡D]R\} } | |k�rtd| ›d�ƒ‚t|| || ƒ\}}}|| | <| | ¡|   |¡qð|  | ¡|  |¡|�s‚t| ƒD]}|  |¡| |¡�qf||fS)Ncs$tˆtƒr|ˆkp"tˆtƒo"|ˆkSr·)rKrÚ)Úcolspec©rir!rFrGÚ_isindex sÿz*_process_date_conversion.._isindexz New date column already in dict z Date column z already in dict)rÚrJrKrXr(rAÚ_try_convert_datesrBr r™rÞr½rËr¯ra)Ú data_dictrZ parse_specrir!rñrwrZnew_colsZnew_datarrrÚnew_namer¡Z old_namesrWrºrFrrGr‚ s^  ÿ    ÿ       r‚c sŽt|ƒ}g}|D]D}||kr(| |¡qt|tƒrJ||krJ| ||¡q| |¡qd dd„|Dƒ¡}‡fdd„|Dƒ}||Ž} || |fS)NrWcss|]}t|ƒVqdSr·rBrCrFrFrGra sz%_try_convert_dates..csg|]}|ˆkrˆ|‘qSrFrFr©rrFrGrb sz&_try_convert_dates..)rJr rKrAr4) r\rrrñÚcolsetÚcolnamesrºrZto_parseZnew_colrFrrGrU s  rcCs´|dkr |rt}ntƒ}tƒ}nŒt|tƒr‚| ¡}i}| ¡D].\}}t|ƒsT|g}|rdt|ƒtB}|||<q>dd„| ¡Dƒ}n*t|ƒs�|g}t|ƒ}|r¤|tB}t|ƒ}||fS)NcSsi|]\}}|t|ƒ“qSrF)Ú_floatify_na_valuesr›rFrFrGr�… sz$_clean_na_values..) rrJrKrÞrÍr½r&Ú_stringify_na_valuesr!)rmrnrÌZ old_na_valuesr˜rœrFrFrGrâh s0   ÿrâc CsØt|ƒsd||fSt|ƒ}t|ƒ}g}t|ƒ}t|ƒD]j\}}t|tƒr„| |¡t|ƒD]&\}}||krZ|||<| |¡q qZq6||}| |¡| |¡q6t|ƒD]"\}}t|tƒrª||krªd||<qª|||fSr·)rÙrÚrrKrÒr ra) rñrir Zcp_colsr!r rºr9rCrFrFrGrE” s*       rEc sòt|ƒ}tˆtƒs,ˆpt‰t‡fdd„ƒ‰nBˆ ¡}tdd„ƒ‰| ¡D]$\}}t|ƒr`||n|}|ˆ|<qH|dks†|dks†|dkr�tgƒ}nF‡fdd„|Dƒ} t | |d�}|  ¡t |ƒD]\} } |  | | ¡q¾‡fdd „|Dƒ} ||| fS) NcsˆSr·rFrF)Ú default_dtyperFrGr©Á rªz!_get_empty_meta..cSstSr·)ÚobjectrFrFrFrGr©Å rªFcsg|]}tgˆ|d�‘qS©r|r5)rrCr|rFrGrØ sz#_get_empty_meta..rMcsi|]}|tgˆ|d�“qSr%r5)rrhr|rFrGr�ß sz#_get_empty_meta..) rÚrKrÞr$rrÍr½r$r1r4r–rr¯) rñrir!rrZ_dtyper˜rœr¡ròrTr rArörF)r#rrrGrŸ¸ s$     rŸc CsPtƒ}|D]@}z t|ƒ}t |¡s,| |¡Wq tttfk rHYq Xq |Sr·)rJÚfloatrÜÚisnanr½rßrBÚ OverflowError)rmrårœrFrFrGr!ä s r!c CsÀg}|D]®}| t|ƒ¡| |¡zHt|ƒ}|t|ƒkr`t|ƒ}| |›d�¡| t|ƒ¡| |¡Wntttfk r†YnXz| t|ƒ¡Wqtttfk r´YqXqt|ƒS)z3 return a stringified and numeric for these values z.0)r rÒr&rArßrBr(rJ)rmrårDrœrFrFrGr"ñ s$  r"cCsJt|tƒr>||kr"||||fS|r0ttƒfStƒtƒfSn||fSdS)a  Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict The object listing the NaN values as floats. keep_default_na : bool If `na_values` is a dict, and the column is not mapped in the dictionary, whether to return the default NaN values or the empty set. Returns ------- nan_tuple : A length-two tuple composed of 1) na_values : the string NaN values for that column. 2) na_fvalues : the float NaN values for that column. N)rKrÞrrJ)r¡rmrÌrnrFrFrGrcs  rccCsFt|ƒ}g}|D]0}||kr(| |¡qt|tƒr| ||¡q|Sr·)rJr rKrA)rrñrr rºrFrFrGÚ_get_col_names1s  r)c@s6eZdZdZd dd„Zd dd„Zddd „Zd d „ZdS)ÚFixedWidthReaderz( A reader of fixed-width lines. NrˆcCsÎ||_d|_|rd|nd|_||_|dkr>|j||d�|_n||_t|jttfƒsht dt |ƒj ›�ƒ‚|jD]Z}t|ttfƒrÀt |ƒdkrÀt|dt tjt dƒfƒrÀt|dt tjt dƒfƒsnt d ƒ‚qndS) Nz z r_)rŠrkz;column specifications must be a list or tuple, input was a rËrrUzEEach column specification must be 2 element tuple or list of integers)r§ÚbufferraruÚdetect_colspecsr‰rKrÛrÚrßràrárIrArÜr)rµr§r‰rarurkrŠrrFrFrGr¶As4ÿ ÿ  ÿ þýüÿzFixedWidthReader.__init__cCsd|dkrtƒ}g}g}t|jƒD]4\}}||kr:| |¡| |¡t|ƒ|kr qVq t|ƒ|_|S)aÉ Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic alone than to modify them to deal with the fact we skipped some rows here as well. Parameters ---------- infer_nrows : int Number of rows to read from self.f, not counting rows that are skipped. skiprows: set, optional Indices of rows to skip. Returns ------- detect_rows : list of str A list containing the rows to read. N)rJrr§r rIrôr+)rµrŠrkZ buffer_rowsZ detect_rowsr rrFrFrGÚget_rows_s    zFixedWidthReader.get_rowsc súd dd„ˆjDƒ¡}t d|›d�¡}ˆ ||¡}|s@tdƒ‚ttt|ƒƒ}t j |dt d�}ˆj dk r|‡fd d „|Dƒ}|D](}|  |¡D]} d||  ¡|  ¡…<qŽq€t  |d¡} d | d <t  || Adk¡d } tt| ddd …| ddd …ƒƒ} | S) Nr¦css|]}d|›�VqdS)ú\NrFrCrFrFrGr‡sz3FixedWidthReader.detect_colspecs..z([^z]+)z(No rows from which to infer column widthrUr|csg|]}| ˆj¡d‘qS)r)Ú partitionrurr¹rFrGr�sz4FixedWidthReader.detect_colspecs..rrË)r4rarºr»r-rrr%rIrÜÚzerosrAruÚfinditerrâräZrollÚwhererÚrF) rµrŠrkÚ delimitersÚpatternrÒrrrrÚmZshiftedÚedgesZ edge_pairsrFr¹rGr,…s"   "z FixedWidthReader.detect_colspecscs`ˆjdk r@ztˆjƒ‰WqJtk r<dˆ_tˆjƒ‰YqJXn tˆjƒ‰‡‡fdd„ˆjDƒS)Ncs$g|]\}}ˆ||… ˆj¡‘qSrF)rÃra)rZfrommÚto©rÄrµrFrGr£sz-FixedWidthReader.__next__..)r+rórér§r‰r¹rFr8rGrÅ™s  zFixedWidthReader.__next__)Nrˆ)N)rˆN)rárrrr¶r-r,rÅrFrFrFrGr*<s   & r*c@s.eZdZdZdd„Zdd„Zedœdd„Zd S) rízl Specialization that Converts fixed-width fields into DataFrames. See PythonParser for details. cKs,| d¡|_| d¡|_tj||f|ŽdS)Nr‰rŠ)r¯r‰rŠrìr¶)rµr§r[rFrFrGr¶¬s  zFixedWidthFieldParser.__init__cCs"t||j|j|j|j|jƒ|_dSr·)r*r‰rarurkrŠrT)rµr§rFrFrGr±²súz"FixedWidthFieldParser._make_readerrbcCsdd„|DƒS)z¿ Returns the list of lines without the empty ones. With fixed-width fields, empty lines become arrays of empty strings. See PythonParser._remove_empty_lines. cSs"g|]}tdd„|Dƒƒr|‘qS)css"|]}t|tƒ p| ¡VqdSr·)rKrÒrÃ)rrórFrFrGrÆszGFixedWidthFieldParser._remove_empty_lines...)r&)rrÄrFrFrGrÃsþz=FixedWidthFieldParser._remove_empty_lines..rFrûrFrFrGrê¼sþz)FixedWidthFieldParser._remove_empty_linesN)rárrrr¶r±r rêrFrFrFrGrí¦s rí)r›rar�ršr’r•cCs–|d}i}|dk r2|dko,|tjkp,||k|d<|dkr>|}|rT|tjk rTtdƒ‚|tjkrh||d<n||d<|dk r‚d|d<nd|d<d |d<|S) arValidate/refine default values of input parameters of read_csv, read_table. Parameters ---------- dialect : str or csv.Dialect If provided, this parameter will override values (default or not) for the following parameters: `delimiter`, `doublequote`, `escapechar`, `skipinitialspace`, `quotechar`, and `quoting`. If it is necessary to override values, a ParserWarning will be issued. See csv.Dialect documentation for more details. delimiter : str or object Alias for sep. delim_whitespace : bool Specifies whether or not whitespace (e.g. ``' '`` or ``' '``) will be used as the sep. Equivalent to setting ``sep='\s+'``. If this option is set to True, nothing should be passed in for the ``delimiter`` parameter. engine : {{'c', 'python'}} Parser engine to use. The C engine is faster while the python engine is currently more feature-complete. sep : str or object A delimiter provided by the user (str) or a sentinel value, i.e. pandas._libs.lib.no_default. defaults: dict Default values of input parameters. Returns ------- kwds : dict Input parameters with correct values. Raises ------ ValueError : If a delimiter was specified with ``sep`` (or ``delimiter``) and ``delim_whitespace=True``. raNÚ sep_overridezXSpecified a delimiter with both sep and delim_whitespace=True; you can only specify one.Tr¥rºršF)rÚ no_defaultrB)r›rar�ršr’r•Z delim_defaultr[rFrFrGr˜Ês(- ÿÿ   r˜)r[r+cCs<| d¡dkrdS|d}|t ¡kr0t |¡}t|ƒ|S)za Extract concrete csv dialect instance. Returns ------- csv.Dialect or None r›N)rWr²Ú list_dialectsÚ get_dialectÚ_validate_dialect)r[r›rFrFrGrª#s  rª)rarerbrfrcrd)r›r+cCs(tD]}t||ƒstd|›d�ƒ‚qdS)zx Validate csv dialect instance. Raises ------ ValueError If incorrect dialect is provided. zInvalid dialect z providedN)ÚMANDATORY_DIALECT_ATTRSrÆrB)r›ÚparamrFrFrGr=As  r=)r›r•r+c Cs | ¡}tD]Ž}t||ƒ}t|}| ||¡}g}||krx||krxd|›d|›d|›d�}|dkrn| dd¡sx| |¡|r’tjd  |¡t d d �|||<q |S) a„ Merge default kwargs in TextFileReader with dialect parameters. Parameters ---------- dialect : csv.Dialect Concrete csv dialect. See csv.Dialect documentation for more details. defaults : dict Keyword arguments passed to TextFileReader. Returns ------- kwds : dict Updated keyword arguments, merged with dialect parameters. zConflicting values for 'z': 'z+' was provided, but the dialect specifies 'z%'. Using the dialect-specified value.rar9Fz rËrÉ) rÍr>Úgetattrr¼rWr¯r rÖr×r4r) r›r•r[r?Z dialect_valrçÚprovidedZ conflict_msgsrErFrFrGr«Os  ÿ   r«cCs<| d¡r8| d¡s| d¡r&tdƒ‚| d¡r8tdƒ‚dS)a Check whether skipfooter is compatible with other kwargs in TextFileReader. Parameters ---------- kwds : dict Keyword arguments passed to TextFileReader. Raises ------ ValueError If skipfooter is not compatible with other parameters. rlrSrTz('skipfooter' not supported for iterationrVz''skipfooter' not supported with 'nrows'N)rWrB)r[rFrFrGr©ƒs   r©)r)r_Nrˆ)N)NFFT)F)T)N)šrÚ collectionsrrr²rÚiorr1rºrÎÚtextwraprÚtypingrrrr r r r r rrrÖÚnumpyrÜZpandas._libs.libZ_libsrZpandas._libs.opsÚopsr{Zpandas._libs.parsersrzrZpandas._libs.tslibsrZpandas._typingrrrZ pandas.errorsrrrrZpandas.util._decoratorsrZpandas.core.dtypes.castrZpandas.core.dtypes.commonrrrrrr r!r"r#r$r%r&r'r(r)r*Zpandas.core.dtypes.dtypesr+Zpandas.core.dtypes.missingr,Z pandas.corer-r.Zpandas.core.arraysr/Zpandas.core.framer0Zpandas.core.indexes.apir1r2r3r4Zpandas.core.seriesr6Zpandas.core.toolsr7rZpandas.io.commonr8r9r:Zpandas.io.date_convertersr;rár4r5Z_doc_read_csv_and_tablerHrOr]Ú QUOTE_MINIMALr¼r¾rÁrÕr¿rŒrÒÚ__annotations__rJr�ÚformatZ _shared_docsr:rŽr�r£rYrÙrXrAr rrrrrrrër¥r¨rìr#r‚rrârErŸr!r"rcr)r*rírÆr$r˜rªr>r=r«r©rFrFrFrGÚs<  0     H       tŒu‹ÿ6 Ù,ù üÿ Æ(ÆHüÿ Ç(×Iüÿ QBÿÿ  2IB<0ÿ 4ù E ,$ , # j%    ú Y   ý 4