• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: I have exported sales data from my ecommerce site to XML. I need help pulling out specific information that is nested within an order using python

Resolved: I have exported sales data from my ecommerce site to XML. I need help pulling out specific information that is nested within an order using python

0
By Isaac Tonny on 15/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve I have exported sales data from my ecommerce site to XML. I need help pulling out specific information that is nested within an order using python

Question:

I want to start by saying I have no experience working with XML files. I just started poking around this data in the past couple of days and have some code that somewhat works, it just needs a couple tweaks. The code I have is here:
Here is the result:
The issue I am having is some of these orders have multiple items on it, and this is not reflecting that. The item data for each order is stored in the tag and then . The code I have does not pick up that there can be multiple ‘s for each . Here is the source code of the XML document for Order ID 515
What I need help with is having the orders that have multiple line items on it, and being able to write that into the pandas dataframe. OrderID 515 should be the SKU from index 3 and index 4.
I was expecting there to be multiple lines for orders with more than one item, instead items from order 515 went to the next line with the next OrderID 516.
Here is the XML for 2 orders:

Best Answer:

Consider relating your iterations with nested looping which you can achieve with comprehensions:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

pandas python xml
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: TYPO3 SQL error: Field ‘tx_imagezoom_set’ doesn’t have a default value

26/03/2023

Resolved: std::regex_replace to replace multiple combinations

26/03/2023

Resolved: How can I copy files using the ansible.builtin.copy module and avoid conflicting file names?

26/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.