These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

[Q] Googlesheets and Googlescript coding issue.

Author
Zand Vor
OpSec.
Wrong Hole.
#1 - 2016-01-04 17:44:14 UTC
So I'm attempting to do the following:

Import all the data via the Eve XML API for one of my Corps wallet.
sumif() on the data, return the total value that each person in the corp has paid to that specific wallet.

I modified one of Steve R's scripts so I could generate a table of all the data I need (Removed the actual API call as the forum wouldn't let me post it as it's a url)

function loadwallet(){
  var wallet= new Array();
  var url (Insert EVEAPI Call Here.)
  var parameters = {method : "get", payload : ""};
  var xmlFeed = UrlFetchApp.fetch(url, parameters).getContentText();
  var xml = XmlService.parse(xmlFeed);
  if(xml) {
    var rows=xml.getRootElement().getChild("result").getChild("rowset").getChildren("row");
    for(var i = 0; i < rows.length; i++) {
      walletinfo=[rows[i].getAttribute("date").getValue(),
                 rows[i].getAttribute("refID").getValue(),
                 rows[i].getAttribute("refTypeID").getValue(),
                 rows[i].getAttribute("ownerName1").getValue(),
                 rows[i].getAttribute("ownerID1").getValue(),
                 rows[i].getAttribute("ownerName2").getValue(),
                 rows[i].getAttribute("ownerID2").getValue(),
                 rows[i].getAttribute("argName1").getValue(),
                 rows[i].getAttribute("argID1").getValue(),
                 rows[i].getAttribute("amount").getValue(),
                 rows[i].getAttribute("balance").getValue(),
                 rows[i].getAttribute("reason").getValue(),
                 rows[i].getAttribute("owner1TypeID").getValue(),
                 rows[i].getAttribute("owner2TypeID").getValue(),
                 ]
      wallet.push(walletinfo);
    }
  }
  return wallet;
}


This code works, I get a nice table full of all the data I need.

The problem I seem to be having is the data TYPE that gets returned is a string. This is ok except I can't perform any MATH functions on this data, like sum() or sumif().
So in the Google Sheet, when I attempt to perform a sumif() function based on the ownerName1 and amount, it returns a 0 every time.

function:
=sumif('Wallet API Pull'!D:D,"ownername",'Wallet API Pull'!J:J)

'Wallet API Pull'!D:D' is the column of Names
"ownername" is a specific name to match against
'Wallet API Pull'!J:J' is the column of Amounts

Do I need to modify the script to make the "amount" data return as number rather than a string and if so...how?
Or do I need to do something with my sheet?

Please fix wormhole combat sites: c1 20mil - c2 40 mil - c3 80 mil - c4 160 mil - c5 320 mil - c6 640 mil

Zad Murrard
Frozen Dawn Inc
Frozen Dawn Alliance
#2 - 2016-01-04 18:24:21 UTC
Prob inserting parseFloat around the value you are interested in would work.

eg.
rows[i].get...,
parseFloat(rows[i].getAttribute..........),
rows[i].get....

In general what I use in importxml2 is:

if (isNaN(attrValue))
{
return attrValue
}
else
{
return parseFloat(attrValue)
}

Zand Vor
OpSec.
Wrong Hole.
#3 - 2016-01-04 19:45:56 UTC
that was it! Thank you!

Please fix wormhole combat sites: c1 20mil - c2 40 mil - c3 80 mil - c4 160 mil - c5 320 mil - c6 640 mil