pkaczynski / xml2xlsx Goto Github PK
View Code? Open in Web Editor NEWpython xml to xlsx converter
python xml to xlsx converter
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
Hi team,
I've tried to contact you in mail but there was no response, can you please contact me ?
Thanks,
- XML2XLSX version: 1.0.1
- Python interpreter version: 3.7.3
- Platform: Darwin-18.6.0-x86_64-i386-64bit
Assume that there is a cell with type
attribute set to date
, which has no value. During the conversion, TypeError
gets thrown by the strptime()
function, as the value of passed argument self._cell.value
is None
, rather than a string, which is expected.
Here is the traceback:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 615, in run
testMethod()
File "/Users/exer2k/code/xml2xlsx/tests/__init__.py", line 169, in test_cell_type_date
sheet = io.BytesIO(xml2xlsx(template))
File "/Users/exer2k/code/xml2xlsx/xml2xlsx/__init__.py", line 237, in xml2xlsx
return etree.XML(xml, parser, )
File "src/lxml/etree.pyx", line 3213, in lxml.etree.XML
File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
File "src/lxml/parser.pxi", line 1757, in lxml.etree._parseDoc
File "src/lxml/parser.pxi", line 1068, in lxml.etree._BaseParser._parseUnicodeDoc
File "src/lxml/parsertarget.pxi", line 192, in lxml.etree._TargetParserContext._handleParseResultDoc
File "src/lxml/parsertarget.pxi", line 180, in lxml.etree._TargetParserContext._handleParseResultDoc
File "src/lxml/etree.pyx", line 318, in lxml.etree._ExceptionContext._raise_if_stored
File "src/lxml/saxparser.pxi", line 485, in lxml.etree._handleSaxEnd
File "src/lxml/parsertarget.pxi", line 99, in lxml.etree._PythonSaxParserTarget._handleSaxEnd
File "/Users/exer2k/code/xml2xlsx/xml2xlsx/__init__.py", line 216, in end
self._cell.value, self._cell_date_format).date()
TypeError: strptime() argument 1 must be str, not None
This can be asserted with the following unit test:
import unittest
from xml2xlsx import xml2xlsx
class CellTest(unittest.TestCase):
def test_empty_cell_type_date(self):
template = """
<sheet title="test">
<row><cell type="date" date-fmt="%d.%m.%Y"></cell></row>
</sheet>
"""
self.assertRaises(TypeError, xml2xlsx, template)
Instead, the script should catch this, leave the cell empty, and continue with the execution. It is a simple fix, and I can provide a pull request if you accept them.
Hi,
i am trying to use your script to convert a standard XML file to XLSX file. I am new to python and i am getting the error lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1.
With a simple script such as
from xml2xlsx import xml2xlsx
def ConvertXmlToXlsx(self):
xml2xlsx("C:\Python27\PythonExcel\\test.xml")
I am not sure how to input my xml file in your function.
thanks
Olivier
Hi team,
I've tried to contact you in mail but there was no response, can you please contact me ?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.