Pages: [1] :: one page |
|
Author |
Thread Statistics | Show CCP posts - 0 post(s) |
Klown Walk
Caldari Provisions Caldari State
222
|
Posted - 2014.09.23 18:19:00 -
[1] - Quote
Hey, I could use some help. I have this so far as a test:
https://docs.google.com/spreadsheets/d/1HNUjWsun1NSvNNof5AmlFwbkSZqqKM8hSVLscDagnVI/edit?usp=sharing
but it doesn't work, all it says is: error loading data, and then it randomly works for a abit where it shows the prices but it doesn't update itself and a few mins after that it goes back into error loading data. I have no idea whats wrong so I could use some help. I looked at some other examples people made and I can't spot anything different in the code. |
VolatileVoid
ELVE Industries Brothers of Tangra
39
|
Posted - 2014.09.26 12:07:00 -
[2] - Quote
What about using a script. Try this one:
function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var menubuttons = [ {name: "Fetch prices", functionName: "loadprices"} ]; ss.addMenu("Api", menubuttons); }
function loadprices() { var sheet = SpreadsheetApp.getActive().getSheetByName('Trade'); var systemID = 30000142;// jita // C1 contains the ID range as string, example: C1:C53 (if you add ID's you just change the range in cell C1) var priceIDs = sheet.getRange(sheet.getRange('C1').getValue()).getValues(); var prices = new Array(); var dirtyTypeIds = new Array(); var cleanTypeIds = new Array(); var url="http://api.eve-central.com/api/marketstat?usesystem="+systemID+"&typeid="; priceIDs.forEach (function (row) { row.forEach ( function (cell) { if (typeof(cell) === 'number' ) { dirtyTypeIds.push(cell); } }); }); cleanTypeIds = dirtyTypeIds.filter(function(v,i,a) { return a.indexOf(v)===i; }); var xmlFeed = UrlFetchApp.fetch(url+cleanTypeIds.join("&typeid=")).getContentText(); var xml = XmlService.parse(xmlFeed); if(xml) { var rows=xml.getRootElement().getChild("marketstat").getChildren("type"); for(var i = 0; i < rows.length; i++) { var price=[rows[i].getChild("sell").getChild("min").getValue(), rows[i].getChild("buy").getChild("max").getValue()]; prices.push(price); } } // fill price data to column D-E (sell/min, buy/max, buy/volume, sell/volume) var dest = 'D3:E' + (prices.length+2); sheet.getRange(dest).setValues(prices); // show datetime of last prices fetch to cell D1 sheet.getRange('D1').setValue(new Date()); }
Delete the 2 importxml functions in D3, E3. Open Tools/Scripteditor in your sheet and copy/paste the 2 scripts and save. Go to your Trade sheet and type the ID range to cell C1 like: C3:C53 Close the sheet and open it again, now you should have an additional menu button Api/Fetch prices. Click that and in D1 should appear a datetime and actual prices should fill. |
Klown Walk
Caldari Provisions Caldari State
222
|
Posted - 2014.09.26 19:48:00 -
[3] - Quote
I think I did what you said but when I press the fetch prices button I get this now: Incorrect range height, was 50 but should be 49 (line 32, file "2" |
Steve Ronuken
Fuzzwork Enterprises Vote Steve Ronuken for CSM
3891
|
Posted - 2014.09.26 21:29:00 -
[4] - Quote
GÇ£There are only two hard things in Computer Science: cache invalidation, naming things and off-by-1 errorsGÇ¥GÇ¥. Woo! CSM 9! http://fuzzwork.enterprises/ Twitter: @fuzzysteve on Twitter |
VolatileVoid
ELVE Industries Brothers of Tangra
39
|
Posted - 2014.09.26 21:48:00 -
[5] - Quote
Sorry for that, the sheet where i copied from started at row 2 so you may change this line: var dest = 'D3:E' + (prices.length+2);
I am sure that this can be automated aswell. |
|
|
|
Pages: [1] :: one page |
First page | Previous page | Next page | Last page |