parsing XML file in python with cElementTree: dealing with errors and line number in the file

I am using the cElementTree library to parse XML files in Python. Everything is working fine But I would like to provide full error messages for the user when a value in the XML is not...

Python 2.5.4 - ImportError: No module named etree.ElementTree

I'm running Python 2.5.4 on Windows and I keep getting an error when trying to import the ElementTree or cElementTree modules. The code is very simple (I'm following a tutorial): import...

django django_authopenid.openid_store error in apache

I am getting the following error on my website: Error importing openid store django_authopenid.openid_store: "No ElementTree library found. You may need to install one. Tried importing...

Is there a way to get a line number from an ElementTree Element

So I'm parsing some XML files using Python 3.2.1's cElementTree, and during the parsing I noticed that some of the tags were missing attribute information. I was wondering if there is any easy way...

Python 2.7 on Google App Engine, cannot use lxml.etree

I've been trying to use html5lib with lxml on python 2.7 in google app engine. But when I run the following code, it gives me an error saying "NameError: global name 'etree' is not defined". Is it...

How to create <!DOCTYPE> with Python's cElementTree

I have tried to use the answer in this question, but can't make it work: https://stackoverflow.com/questions/1070772/how-to-create-virtual-root-with-pythons-elementtree Here's my code: import...

Programmatically DOC/DOCX to PDF

I'm having an issue trying to convert DOC/DOCX to PDF programmatically. I'm following this answer. I'm using PyODConverter as mentioned in the answer above. I asked my web hosting to install...

Efficiently parsing broken XML/HTML in python

I would like to be able to efficiently parse large HTML documents in Python. I am aware of Liza Daly's fastiter and the similar concept in the Python's own cElementTree. However, neither of these...

how to set supervisor to run a shell script

Setting up a Dockerfile to install node prereqs and then set up supervisor in order to run the final npm install command. Running Docker in CoreOS under VirtualBox. I have a Dockerfile that sets...

Using cElementTree in python 3

cElementTree is the fast, C implementation of the XML API ElementTree. In python 2 you would load it explicitly (aliasing it to ElementTree), but in the Python 3 docs I read this: Changed in...

py2exe fails to create .exe due to missing modules

I've been programming a python program that uses resources from a precompiled Python 2.7 binary. I'm using MIT's Name Entity Recognition tool found here. I'm trying to make my .py into a .exe...

TypeError: write() got an unexpected keyword argument 'pretty_print'

I am writing a python script which will append a new Tag/elment in config.xml of my jenkins job. This is how my script looks like:- #!/usr/bin/python import os, fnmatch, pdb, re, string,...

Continue "for" loop after "if" statement

I have an xml file that look like this: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="pdml2html.xsl"?> <pdml version="0" creator="wireshark/1.12.4" time="Sat Aug 15 11:18:38 2010"...

Translate xml string to Python list

I am new to Python. I want to show this XML string as a list in a template. xmlData = """<?xml version="1.0" encoding="utf-8"?> <django-objects version="1.0"> <object model="task.task"...

How to get all text children of an element in cElementTree?

I'm using the cElementTree module in Python to get the text child of an XML tree, using the text property. But it seems to work only for the immediate text children (see below). $ python ... >>>...

Parsing XML in Python using the cElementTree module

I have an XML file, which I wanted to convert to a dictionary. I have tried to write the following code but the output is not as expected. I have the following XML file named...

How to parse XML in python using the cElementTree?

I am trying to parse the xml using the cElementTree library in python.But when i am trying to run the program it gives me error. #!/usr/bin/python import os import xml.etree.ElementTree as...

Error in XML file reading via xml.etree

I am trying to read a XML file in python using xml.etree but sometimes for some files I get memory error while parsing the file. My XML file size is 912Mb, Is the issue related to file...

python behave generates XML that is "Not well-formed"

I am using python behave for about 40 tests that I run. Now I am trying to make a more-or-less decent looking HTML report for myself and my client. I run the tests via commandline: behave...

How to take a systematic sample of elements from OSM file

I am trying to take a systematic sample of elements from a large OSM file , but I am getting "a bytes-like object is required, not 'str'" error. Here is the code I am using #!/usr/bin/env...

cElementTree insatall in Ubuntu

How to install cElementTree on Ubuntu where python 2.7 is present, Need Version 1.0.5 Python 2.7.6 (default, Oct 26 2016, 20:32:47) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or...

parse xml files block by block and get the values inside each block

I have a 10 GB xml file which include list of different blocks. Here is a snippet of my file: <image> <ref>www.test.com</ref> <label/> <number>0</number> <ID>ID0</ID> ...

Segmentation fault (core dumped) with cElementTree on ubuntu

I am parsing xml files on a linux ubuntu machine using a python script and the cElementTree package. After a while (at the same point every time) it results in the error Segmentation fault (core...

Which is the better way to handle ImportError - Raise error or import chain?

Question When encounter ImportError in python, should I directly raise the error and ask the user to install it, or should I use import chain? Description I came across this question when I tried...

cElementTree to extract data from XML python

I have an XML file whose structure is similar to the following: <?xml version="1.0" encoding="UTF-8"?> <drugbank xmlns="http://www.drugbank.ca"...

Converting xml to txt in python

I am using python 3.6 and want to convert/write some information from my .x81-file (which looks just like xml) to a .txt-file. I keep on getting "a bytes-like object is required, not...

AttributeError: module 'Bio.SeqIO' has no attribute 'parse'

The codes which import Biopython and parse the files have worked on my laptop. Now I have a very big file that I can only parse it on another computer which also have installed python and...

iterparse elements getting cleared before I can capture the data

I'm trying to use Python to parse a large XML file (27GB) using cElementTree and iterparse. I'm able to extract all the tags, but for some reason none of the element text is being retrieved (its...

Creating an adjacency matrix from XML in Python

I am trying to create an adjacency matrix of *t_lemma* (other elements like nodetype, ord, etc. can be ignored, I am including them just for completness in case they are somehow needed) - meaning...

URL in all XML Element Tags

I am using the cElementTree package in Python and am having trouble with the element's tags. They include an attribute in the tag itself. It seems to be a problem with the parser. Please review...