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

2016-01-11 Thread Saran Ahluwalia
Hi Steven: Just as an update - apparently there were bytes in the Windows Command Terminal that were interrupting the process execution. I didn't realize this was happening until I dug around Windows' Q&A forum. Cheers On Sun, Jan 10, 2016 at 12:53 PM, Saran Ahluwalia &l

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

2016-01-10 Thread Saran Ahluwalia
Hi Steven: The previous code was a stand along under the " if __name__ == '__main__': ". The full function suite that I have made (and indeed includes a try and except block): import os.path import sys import csv from io import StringIO import xml.etree.cElementTree as ElementTree from xml.etree.

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

2016-01-10 Thread Saran Ahluwalia
Hi Steven: That is the only message (*xml.etree.ElementTree.Element' does not support the buffer interface"*). There is no traceback. My apologies for not clarifying previously. On Sun, Jan 10, 2016 at 10:19 AM, Steven D'Aprano wrote: > On Mon, 11 Jan 2016 02:04 am, kbtyo wrote: > > > Hello Eve

Re: Understanding how to quote XML string in order to serialize using Python's ElementTree

2016-01-09 Thread Saran Ahluwalia
Thank you for the feedback on this. I believe that the excel dialect includes just that: class excel(Dialect): delimiter = ',' quotechar = '"' doublequote = True skipinitialspace = False lineterminator = '\r\n' quoting = QUOTE_MINIMAL On Sat, Jan 9, 2016 at 5:23 PM, Karim

Re: Understanding how to quote XML string in order to serialize using Python's ElementTree

2016-01-09 Thread Saran Ahluwalia
As mentioned previously, I assigned the variable *data *to the string ''',0001,0070,". When any utility that attempts to parse this string (this is one example of millions found in my actual data source) you receive that error. You would need to comment out the following: data = row['E

Re: AttributeError: 'module' object has no attribute '__path__'

2015-08-31 Thread Saran Ahluwalia
Laura, It does not appear to be the case. I actually had to actually unset the PYTHONPATH. Thanks for your suggestion. Sincerely, Saran On Mon, Aug 31, 2015 at 4:17 PM, Laura Creighton wrote: > Check and see if you have a file in your working directory with the > very same name as a module yo

Re: GOTCHA with list comprehension

2015-08-07 Thread Saran Ahluwalia
@ChrisA You, my friend, certainly put the nail in the coffin! Sent from my iPhone > On Aug 5, 2015, at 5:52 AM, Chris Angelico wrote: > >> On Wed, Aug 5, 2015 at 7:01 PM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> You can chain 'for' and 'if' clauses as much as you like, and they >>> beh

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Saran Ahluwalia
So what did you do to resolve this? Please provide your fix. This is an excellent case study for others. Sent from my iPhone > On Jul 2, 2015, at 5:34 AM, Veek M wrote: > > never mind fixed.. > > it's returning a list so whatever[0].text and relative-path for the xpath > > > > > -- > htt

Re: To write headers once with different values in separate row in CSV

2015-06-23 Thread Saran Ahluwalia
It was an XML formatting issue; apparently you have to explicitly call a delimiter via the Command Prompt on my OS. IPython Notebook seems to make certain assumptions regarding read and write. On Tue, Jun 23, 2015 at 3:12 PM, John Gordon wrote: > In Sahlusar < > ahlusar.ahluwa...@gmail.com> wri

Re: JSON Object to CSV Question

2015-06-20 Thread Saran Ahluwalia
Here is the dictionary that corresponds with the CSV printed to the console: 1. { 2. "PAC": { 3. "Account": [{ 4. "PC": "0", 5. "CMC": "0", 6. "WC": "0", 7. "DLA": "0", 8. "CN": null, 9. "FC": { 10. "Int32": ["0", 11. "0", 12. "0", 13. "0", 14. "0"] 15

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
My answers are below in red. On Fri, Jun 19, 2015 at 2:47 PM, Joonas Liik wrote: > > You say you are taking this from an xml file and want to get a CSV file.. > > Why are you making an intermediate JSON file? > I thought that this would be the most efficient method as it emulates Python diction

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
@Joonas: The previous example was a typo. Please use the below example as a case study. 1. {'D_B': ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 2. 'F_Int32': ['0', 3. '0', 4. '0', 5. '0', 6. '0', 7. '0', 8. '0', 9. '0', 10. '0', 11. '0', 12. '0',

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
other iterable object is not the best strategy. The list objects cannot be accessed (hence, the "ValueError: too many values to unpack") is caught at the function json.loads(). I am wondering how to add the exception when 1) when one encounters the list and 2) how to delete and re-as

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
Thank you for clarifying. I will be more cognizant to follow this protocol. Sent from my iPhone > On Jun 19, 2015, at 6:07 AM, Cecil Westerhof wrote: > > Top posting is frowned upon. Could you put your reply under where you > reply on next time? > >> On Friday 19 Jun 2

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
17:49:35 -0400, Saran Ahluwalia > wrote: > >> Good Evening Everyone: >> >> I would like to have this JSON object written out to a CSV file so that the > > You've already said that in another thread, and got several answers. > What are you? Some kind of troll

JSON Object to CSV Question

2015-06-18 Thread Saran Ahluwalia
Good Evening Everyone: I would like to have this JSON object written out to a CSV file so that the keys are header fields (for each of the columns) and the values are values that are associated with each header field. Is there a best practice for working with this? Ideally I would like to recursiv

Addendum to Strategy/ Advice for How to Best Attack this Problem?

2015-03-29 Thread Saran Ahluwalia
On Sunday, March 29, 2015 at 7:33:04 AM UTC-4, Saran Ahluwalia wrote: > Below are the function's requirements. I am torn between using the OS module > or some other quick and dirty module. In addition, my ideal assumption that > this could be cross-platform. "Records"

Strategy/ Advice for How to Best Attack this Problem?

2015-03-29 Thread Saran Ahluwalia
Below are the function's requirements. I am torn between using the OS module or some other quick and dirty module. In addition, my ideal assumption that this could be cross-platform. "Records" refers to contents in a file. What are some suggestions from the Pythonistas? * Monitors a folder for

Second Pair of eyes for Correctly writing out XML from DataFrame (Pandas)?

2015-03-29 Thread Saran Ahluwalia
I would appreciate feedback on whether I correctly exported my DataFrame and wrote into XML. I used the ElementTree library. My DataFrame has 11 rows and 8 columns (excluding the index column) For your convenience here it is: #My schema assumption: # #[ #Some number row #Sa