BUG: read_xml not support large file (original) (raw)
Pandas version checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
df = pd.read_xml('202201140700.xml') Traceback (most recent call last): File "", line 1, in File "/home/miniconda3/envs/metenv/lib/python3.8/site-packages/pandas/io/xml.py", line 927, in read_xml return _parse( File "/home/miniconda3/envs/metenv/lib/python3.8/site-packages/pandas/io/xml.py", line 728, in _parse data_dicts = p.parse_data() File "/home/miniconda3/envs/metenv/lib/python3.8/site-packages/pandas/io/xml.py", line 391, in parse_data self.xml_doc = XML(self._parse_doc(self.path_or_buffer)) File "/home/miniconda3/envs/metenv/lib/python3.8/site-packages/pandas/io/xml.py", line 553, in _parse_doc doc = fromstring( File "src/lxml/etree.pyx", line 3237, in lxml.etree.fromstring File "src/lxml/parser.pxi", line 1896, in lxml.etree._parseMemoryDocument File "src/lxml/parser.pxi", line 1784, in lxml.etree._parseDoc File "src/lxml/parser.pxi", line 1141, in lxml.etree._BaseParser._parseDoc File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError File "", line 61504 lxml.etree.XMLSyntaxError: internal error: Huge input lookup, line 61504, column 702
Issue Description
lxml.etree.XMLSyntaxError: internal error: Huge input lookup, line 61504, column 702
Expected Behavior
read_xml nead add huge_tree=True
in pandas/io/xml.py
for example:
Old parse_data
:
self.xml_doc = XML(self._parse_doc(self.path_or_buffer))
New:
curr_parser = XMLParser(encoding=self.encoding,huge_tree=True) self.xml_doc = XML(self._parse_doc(self.path_or_buffer), parser=curr_parser)
Old _parse_doc
:
curr_parser = XMLParser(encoding=self.encoding)
New:
curr_parser = XMLParser(encoding=self.encoding,huge_tree=True)
Installed Versions
pd.show_versions()
INSTALLED VERSIONS
commit : f00ed8f
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1127.13.1.el7.x86_64
Version : #1 SMP Tue Jun 23 15:46:38 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.0
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.1.3
setuptools : 52.0.0.post20210125
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.22.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : 2021.07.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.0
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.19.0
xlrd : None
xlwt : None
numba : None