Python Forum
Convert xml to dict and group data and sum totals
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert xml to dict and group data and sum totals
#1
Hello,

I have xml file with data.
What I need to do. Group data by siteid and merchantname and sum totals from clicks, downloads, newdepositingacc, netrevenue, revsharecommission.
The result I would like to achieve could be something like this:
[{
  'name': 'http://gamblerguy.com (LeoMonaco)',
  'clicks': 'sum clicks totals',
  'downloads': 'sum clicks downloads',
  'newdepositingacc': 'sum newdepositingacctotals',
  'netrevenue': 'sum netrevenue totals',
  'revsharecommission': 'sum revsharecommission totals' 
},
{
  'name': 'casinochimp.com (LeoMonaco)',
  'clicks': 'sum clicks totals',
  'downloads': 'sum clicks downloads',
  'newdepositingacc': 'sum newdepositingacctotals',
  'netrevenue': 'sum netrevenue totals',
  'revsharecommission': 'sum revsharecommission totals'
}]
Reply
#2
So, what have you done already and where are you stuck? It would be helpful to see a sample of the XML as well.
Reply
#3
In the evening (UTC +3) I will put how far I am. I've grouped the data but got stuck calculating the totals, don't know how correctly do that. Sample xml you can find here https://www.dropbox.com/s/v9avcxaq12hay5i/ocs.xml?dl=0
Reply
#4
At this moment I have something like this https://repl.it/repls/TubbyWideFactors
list of lists but in each list I want get totals
Reply
#5
I solved my problem https://repl.it/@kashcode/TubbyWideFactors
Reply
#6
I suspect that Pandas would be very useful to handle the problem. Pandas comes with rich set of data processing features, e.g. grouping operations, descriptive statistics, i/o operations and much more. If this is not an assignment, I would definitely recommend Pandas to solve such a problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert File to Data URL michaelnicol 3 1,080 Jul-08-2023, 11:35 AM
Last Post: DeaD_EyE
  openpyxl convert data to float jacklee26 13 5,714 Nov-19-2022, 11:59 AM
Last Post: deanhystad
  Convert nested sample json api data into csv in python shantanu97 3 2,725 May-21-2022, 01:30 PM
Last Post: deanhystad
  How to convert binary data into text? ZYSIA 3 2,585 Jul-16-2021, 04:18 PM
Last Post: deanhystad
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,559 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  What type of *data* is the name of a list/tuple/dict, etc? alloydog 9 4,255 Jan-30-2021, 07:11 AM
Last Post: alloydog
Star Recursively convert nested dicts to dict subclass Alfalfa 1 2,840 Jan-22-2021, 05:43 AM
Last Post: buran
  Binary data to Image convert Nuwan16 1 5,562 Aug-24-2020, 06:03 AM
Last Post: millpond
  Sort a dict in dict cherry_cherry 4 62,501 Apr-08-2020, 12:25 PM
Last Post: perfringo
  Convert dict from list - HELP! PLEASE! cherry_cherry 4 2,681 Apr-06-2020, 06:39 PM
Last Post: cherry_cherry

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020