MCPcopy
hub / github.com/pandas-dev/pandas / _parse

Function _parse

pandas/io/xml.py:748–836  ·  view source on GitHub ↗

Call internal parsers. This method will conditionally call internal parsers: LxmlFrameParser and/or EtreeParser. Raises ------ ImportError * If lxml is not installed if selected as parser. ValueError * If parser is not lxml or etree.

(
    path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str],
    xpath: str,
    namespaces: dict[str, str] | None,
    elems_only: bool,
    attrs_only: bool,
    names: Sequence[str] | None,
    dtype: DtypeArg | None,
    converters: ConvertersArg | None,
    parse_dates: ParseDatesArg | None,
    encoding: str | None,
    parser: XMLParsers,
    stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None,
    iterparse: dict[str, list[str]] | None,
    compression: CompressionOptions,
    storage_options: StorageOptions,
    dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
    **kwargs,
)

Source from the content-addressed store, hash-verified

746
747
748def _parse(
749 path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str],
750 xpath: str,
751 namespaces: dict[str, str] | None,
752 elems_only: bool,
753 attrs_only: bool,
754 names: Sequence[str] | None,
755 dtype: DtypeArg | None,
756 converters: ConvertersArg | None,
757 parse_dates: ParseDatesArg | None,
758 encoding: str | None,
759 parser: XMLParsers,
760 stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None,
761 iterparse: dict[str, list[str]] | None,
762 compression: CompressionOptions,
763 storage_options: StorageOptions,
764 dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
765 **kwargs,
766) -> DataFrame:
767 """
768 Call internal parsers.
769
770 This method will conditionally call internal parsers:
771 LxmlFrameParser and/or EtreeParser.
772
773 Raises
774 ------
775 ImportError
776 * If lxml is not installed if selected as parser.
777
778 ValueError
779 * If parser is not lxml or etree.
780 """
781
782 p: _EtreeFrameParser | _LxmlFrameParser
783
784 if parser == "lxml":
785 lxml = import_optional_dependency("lxml.etree", errors="ignore")
786
787 if lxml is not None:
788 p = _LxmlFrameParser(
789 path_or_buffer,
790 xpath,
791 namespaces,
792 elems_only,
793 attrs_only,
794 names,
795 dtype,
796 converters,
797 parse_dates,
798 encoding,
799 stylesheet,
800 iterparse,
801 compression,
802 storage_options,
803 )
804 else:
805 raise ImportError("lxml not found, please install or use the etree parser.")

Callers 1

read_xmlFunction · 0.70

Calls 5

_EtreeFrameParserClass · 0.85
_LxmlFrameParserClass · 0.70
_data_to_frameFunction · 0.70
parse_dataMethod · 0.45

Tested by

no test coverage detected