Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93192
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: 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) |
| Date | 2015-06-26 07:44 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <mmivtd$fqa$1@dont-email.me> (permalink) |
| References | <14aeae7a-41ab-4619-8331-7995e2420e54@googlegroups.com> |
On Thu, 25 Jun 2015 11:39:53 -0700, kbtyo 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 I suggest you look on stack overflow for the answer. You appear to have failed to comprehend (again) the fact that the xml data is an unordered list, and are trying to assign an order to it. If the xml data was ordered, either each tag would be different, or each tag would have an attribute specifying a sequence number. If the original data is ordered, then you need to go back to the code that creates the xml and make it add the ordering information to the xml (ideally as an attribute of the tags concerned) to specify the order. You can not reliably and with any certainty of being accurate try and assign some sequence to the list of similarly named elements simply from their position in the list. You don't know if the code that creates the xml is walking the array like this: i = sizeof(arr); while (i--) addXmlElement(arr[i]); or like this: for (i = 0; i < arr.len; i++) addXmlElement(arr[i]); or even like this: while (sizeof(arr)) addXmlElement(popArrElement(arr[sizeof(arr)/2])); Granted the latter is unlikely and perverse, but still not wholly impossible. More perverse and less likely mechanisms are also available. But my point remains - that if the ordering data is not passed into the xml, then you can not magically add it when you later use the xml. -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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) kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-06-25 11:39 -0700
Re: 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) Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-26 07:44 +0000
Re: 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) Stefan Behnel <stefan_ml@behnel.de> - 2015-06-28 09:46 +0200
Re: 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) Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-28 21:00 +0000
Re: 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) Ned Batchelder <ned@nedbatchelder.com> - 2015-06-28 17:07 -0700
Re: 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) Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-30 00:54 +0000
Re: 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) Robert Kern <robert.kern@gmail.com> - 2015-06-30 10:16 +0100
Re: 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) Marko Rauhamaa <marko@pacujo.net> - 2015-06-30 19:32 +0300
Re: 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) Robert Kern <robert.kern@gmail.com> - 2015-06-29 14:04 +0100
Re: 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) Sahlusar <sahluwalia@wynyardgroup.com> - 2015-06-29 07:52 -0700
Re: 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) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-06-29 21:26 -0400
Re: 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) Chris Angelico <rosuav@gmail.com> - 2015-06-30 22:40 +1000
csiph-web