[Tutor] Newbie to Python: enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to "stacked" values with one header)

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Jun 26 02:36:02 CEST 2015


On 25/06/2015 23:51, Alan Gauld wrote:
> On 25/06/15 19:42, Saran Ahluwalia wrote:
>> My question can be found here:
>>
>> http://stackoverflow.com/questions/31058100/enumerate-column-headers-in-csv-that-belong-to-the-same-tag-key-in-python
>>
>
> It would have been helpful to post the question here rather than just a
> link.
>
> However, having read it, I'm still not sure what you want to do?
> It seems your input file (the XML one?) has multiple ObjectGuid tags?
> And you want to write them out to a CSV file with a number appended
> (objectGuid_1, ObjectGuid_2 etc) Is that right? If so what exactly is
> the issue - it seems simple enough (given your obvious coding
> experience) to store a counter and create a new string each time you
> find a GUID tag?
>
> But I still don't understand how these tags relate to the rest of the
> data in the file? Are you only extracting the GUID and want one row per
> file? Or are you extracting multiple data structures and creating a row
> for each? In which case are the multiple GUID embedded in each data
> structure? I'm really not sure what you are trying to do.
>
>> Here is an additional sample sample of the XML that I am working with:
>
> I have no idea how that is supposed to help? It doesn't have any
> ObjectGUID tags that I can see? It is essentially meaningless
> data (to us).
>

I wouldn't be inclined to put too much into this, it's already been 
asked on the main mailing list and appears to be a follow up to an 
earlier thread.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list