Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

kbtyo ahlusar.ahluwalia at gmail.com
Sun Jan 10 10:04:54 EST 2016


Hello Everyone:

I am curious to know why I receive the aforementioned message. I am using Python 3.4.3 and Windows 7. I am running the following script from Windows Powershell:


	Response = 's.csv'
	with open(Response, 'rU', encoding='utf-8') as data:
	    separated = data.read().split('","')
	    x = ElementTree.XML(separated[3])
	    y = ElementTree.XML(separated[4])
	    print(dict(flatten_dict(x)))
	    print(dict(flatten_dict(y)))

I am importing ElementTree as follows:

import xml.etree.cElementTree as ElementTree
from xml.etree.ElementTree import XMLParser


The input data is as follows:

A,B,C,D,E,F,G,H,I,J
"3","8","1","<Request TransactionID="3" RequestType="FOO"><InstitutionISO /><CallID>23</CallID><MemberID>12</MemberID><MemberPassword /><RequestData><AccountNumber>2</AccountNumber><AccountSuffix>85</AccountSuffix><AccountType>S</AccountType><MPIAcctType>Checking</MPIAcctType><TransactionCount>10</TransactionCount></RequestData></Request>","<Response TransactionID="2" RequestType="HoldInquiry"><PulledLoans>True</PulledLoans><PulledClosedLoans>False</PulledClosedLoans><PulledInvestments>False</PulledInvestments><PulledClosedInvestments>False</PulledClosedInvestments><PulledCards>False</PulledCards><ShareList>0000',0001,0070,</ShareList></Response>","1967-12-25 22:18:13.471000","2005-12-25 22:18:13.768000","2","70","0"

Oddly, when I run the same script via WinPython' Jupyter Notebook, it works perfectly. The input string is an XML string and I am only interested in the 4th and 5th columns, (using zero based indexing). 

Thank you, in advance for your feedback and support. 



More information about the Python-list mailing list