On Mon, 11 Jan 2016 02:04 am, kbtyo wrote: > 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:
I created a file "data" containing the input data you said: > 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" and then a script containing the code you said you used: > import xml.etree.cElementTree as ElementTree > from xml.etree.ElementTree import XMLParser > 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 get a completely different error to you, complete with traceback as expected: Traceback (most recent call last): File "/tmp/testxml.py", line 9, in <module> print(dict(flatten_dict(x))) NameError: name 'flatten_dict' is not defined This shows me three things: (1) The calls to ElementTree.XML work fine, and don't raise an exception; (2) There is no error message referring to xml.etree.ElementTree.Element or the buffer interface; (3) The code you posted is clearly not the code you actually ran. At the very least, it is not *all* the code you ran. We cannot tell what it wrong with your code if you don't show us the code that fails. I suggest you read this webpage: http://www.sscce.org/ and follow the advice given. It's written for Java, but applies to any programming language. Hopefully you will either solve your problem, or be able to generate a sufficiently small piece of code that we can work with. You also suggest that your code works when running in a Jupyter Notebook. It is unlikely (but not impossible!) that exactly the same code will run differently when run as a script and when run under Jupyter. More likely, there is some difference between the code, something you have written in the Notebook but not included in the script. If it is exactly the same code, then perhaps it is a difference in the two environments. Does Jupyter set up the environment differently to what you get when running a script? Finally, in another post, you state: "That is the only message (*xml.etree.ElementTree.Element' does not support the buffer interface"*). There is no traceback." That is very unlikely with the code sample you posted. If true, that gives more evidence that you are running code which is different from what you have posted here. Perhaps your ACTUAL code (not the pretend code you showed us) includes a try...except block like this: try: some code goes here except Exception as err: print(err) sys.exit() or similar. If so, TAKE IT OUT. That is destroying useful debugging information and making it more difficult to solve your problem. -- Steven -- https://mail.python.org/mailman/listinfo/python-list