赞
踩
原创答案来自stackflow
- import pandas as pd
- from xml.sax import ContentHandler, parse
-
- # Reference https://goo.gl/KaOBG3
- class ExcelHandler(ContentHandler):
- def __init__(self):
- self.chars = [ ]
- self.cells = [ ]
- self.rows = [ ]
- self.tables = [ ]
- def characters(self, content):
- self.chars.append(content)
- def startElement(self, name, atts):
- if name=="Cell":
- self.chars = [ ]
- elif name=="Row":
- self.cells=[ ]
- elif name=="Table":
- self.rows = [ ]
- def endElement(self, name):
- if name=="Cell":
- self.cells.append(''.join(self.chars))
- elif name=="Row":
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。