I'm trying to import data For a large number of dates from here: https://demanda.ree.es/movil/peninsula/demanda/tablas/2014-11-03/2
Once/if that's possible I want to automate it so it retrieves the data for a given set of dates. Say, entire 2013.
I can't find anything in the webpage source that would give a hint as to from where the data is retrieved from. I've tried importing the data both using:
Data/From Web: Gets javascript error
Open/ Other web locations: Just retrieves a worksheet filled with grey cells, no data.
Thanks for any help!
Use the following links:
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/maxMinPeninsula?callback=angular.callbacks._0&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/prevProgPeninsula?callback=angular.callbacks._1&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/coeficientesCO2?callback=angular.callbacks._3&curva=DEMANDA&fecha=2013-01-01
Use the "fecha" parameter to set the date. It seems it is not possible to get the whole year at once so you should iterate the calls to that link and change "fecha" to 2013-01-02, 2013-01-03, etc. for each month.
Muchas gracias #miguel-febres! It now works more or less*. Where did you find the links from? :)
It runs some 10-20 loops and returns an address error, upon which I just start the macro again and it works... strange.
Sub Macro1()
Application.DisplayAlerts = False
Do
Workbooks.OpenText Filename:="https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=" & ActiveCell.Value & ""
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("Spain").Activate
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
'close table
Windows("demandaGeneracionPeninsula").Activate
ActiveWindow.Close
ActiveCell.Offset(-1, 1).Activate
Loop Until ActiveCell.Value = ""
End Sub
Now I just have to parse the results.. :)
Related
When I tried to get table data as json, I could find distinguishable children in json output of the following query:
https://en.wikipedia.org/w/api.php?action=parse&page=List_of_football_clubs_in_India&prop=wikitext§ion=3&format=json
I want to get the rows and columns of this table (the text) :-
https://en.wikipedia.org/wiki/List_of_football_clubs_in_India#Assam
The JSON output seems complicated and I don't find a good way to extract text from it.
(I am doing this in Javascript (Node.js)
Please help..
I'm not sure, what you expect. Your API request to the page is actually returning the wikitext encapsulated into a JSON structure. However, the wikitext (where the table is part of) is not JSON, so you can not really interpret it as such.
I'm also not quite sure, what information you want to have. If you want to have the football clubs in the table, then your only bet is to parse the wikitext (you can also return the actual parsed HTML from the API to make it "easier") and go through the data yourself. However, this is probably an error prone and not fun task.
So, if you want to get all football clubs of india in a structured data format, I would probably better try Wikidata for that. It allows you to crunch structured data for the information you need (and also get you the links to Wikipedia articles, if the objects has a link to a Wikipedia page). In your use case, it's probably a good idea to try out the Wikidata Query service.
There you could issue a query like:
SELECT ?itemLabel ?sitelink WHERE {
?item wdt:P31 wd:Q476028;
wdt:P17 wd:Q668.
?sitelink schema:isPartOf <https://en.wikipedia.org/>;
schema:about ?item.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
which queries a list of all football clubs in India and returns you a list with the item label as well as the link to the english Wikipedia article:
https://query.wikidata.org/#SELECT%20%3FitemLabel%20%3Fsitelink%20WHERE%20%7B%0A%20%20%3Fitem%20wdt%3AP31%20wd%3AQ476028%3B%0A%20%20%20%20%20%20%20%20wdt%3AP17%20wd%3AQ668.%0A%20%20%3Fsitelink%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wikipedia.org%2F%3E%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20schema%3Aabout%20%3Fitem.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D
Assume that this is the res is the data that you get from the wiki
//This will get you the innermost part of the object which is the text you want
let wikiText = res.parse.wikitext['*'];
//This will strip out all the numbers and non-alphabet charater.
let pureText=wikitext.replace(/[^a-zA-Z\s]+/g, ' ');
The above code can give you clean access to the text; however, how you are going to separate the column and row is up to you.
This will slow down performance a bit (It seems, but I'm not sure if any other faster way exists).
This can be done by setting prop=text and then parsing the obtained HTML using JSDOM (comes with/for Node.js)
I know this question is old but there is an API for this. You can supply a page title and it will return the tables of your choice in JSON.
I'm trying to convert order form data submitted from a Squarespace website from the following format to a table with 4 columns:
Store,Item,Quantity,Details;Store2,Item2,Quantity2,Details2; (etc...)
Commas separate columns while semi-colons separate rows.
All the methods I've tried so far have been successful in splitting the data into the desired form, but the problem occurs when new data is added. When the form is submitted, it creates a new row in the next available empty row. I can't seem to find a way to automate the process without receiving cyclical dependency errors, since each order can have any amount of item entries.
Example spreadsheet:
https://docs.google.com/spreadsheets/d/1ZEWtmMiWO0Us76Z7o7GB7Salw1Rl_-1PhK6GzeOD0GM/edit?usp=sharing
The above example splits the data as desired. I cannot figure out how to make it work with the data added as a new row. I would also like to continue using sheets for its cloud functionality.
Any advice is appreciated, including entirely new ways of processing the data, whether with a script, a different remotely accessible order processing app compatible with Squarespace forms, or natively within Sheets.
You want to achieve the following conversion.
Sample formula:
=ARRAYFORMULA(SPLIT(TRANSPOSE(split(A4,";")),","))
In this formula, the cell "A4" has the input value.
You have already used the formula of =TRANSPOSE(split(A10,";")). In this answer, I used this.
For TRANSPOSE(split(A10,";")), the value is splitted with , using SPLIT and ARRAYFORMULA.
Result:
Sample script:
When you want to use Google Apps Script, you can also use the following script.
function myFunction(value) {
const values = value.split(";");
return values.splice(0, values.length - 1).map(e => e.split(",").map(f => isNaN(f) ? f : Number(f)));
}
In this case, please copy and paste the script to the script editor, and put the custom function of =myFunction(A4) to a cell.
The same result with above formula can be obtained.
References:
SPLIT
ARRAYFORMULA
split()
map()
I have a recursive data structure to be fetched and displayed. I have a graph ql type as follow:
human {
name,
children: [human]
}
Now I wanted to incrementally fetch data and hence used to react classes HumanList and HumanItem, where I've used relay to fetch children only when a item is clicked. In my actual code relay gives children a null on very click i.e. on rendering very first set of children. I tried test code on relay playground and found similar issue. Here is the link to gist. Playground.js contains the code part and Playground.gql.js contains schema part. Clicking on each number open children under it. After 3 or 4 level it starts showing Found children as null. For me it happens on 1.1.2.2. If it doesn't happens so for you then try adding more levels in SCHEMA code and the bug would pop in.
I've already checked relay issues #246 and #536 but none of them helped.
Any help is very much welcome.
This was a bug. Given a plural field, when the time came to make a query for new data, we would diff what we have in the store with what the application wants. The bug was that we would assume that all records of a plural field have the same shape in the store, and only use the first store record in any plural field against which to diff. This was of course not true in your case, where some records in a plural field might be expanded and some might be collapsed.
This has been fixed as part of https://github.com/facebook/relay/issues/1243 and will be released in the version after Relay 0.9.1.
In my Firebug, it is showing me:
TypeError: this[r]._ticks[0] is undefined
But in my JS Array, the items are well constructed. Should not be the data problem.
So, as i said it should not be the data problem. The mystery is:
The problem is not consistent, just that SOMETIME JUST GOT WHOLE BLANK.
I have multiple log ranges (e.g, Show 1 week, Show 1 day, Show 1 hour), then sometime some got BLANK like now and at the same time, graphs are OK in some time ranges. And next time, this range got OK and next range got problem. (With this same code, same data)
I am super sure all my Array Rooms are filled with respective data inside. (I got no blank or corrupted array rooms)
I'm outta idea already :S
Please help.
I have the same problem this day, and resoled this by hard coding the second array value is number but not string type. You can do this simply in php code: $output["1"]=(double)$var, then try to use json_encode to output the data.
Here is the difference example:
valid array format:
var data=[[['2014-01', 2],['2014-02',5.12],['2014-03',13.1],['2014-04',33.6],['2014-05',85.9],['2014-06',219.9],['2014-07',39.9],['2014-08',99.9]]];
invalid array format:
var data=[[["2014-02","1920.97"],["2014-03","2040.92"],["2014-04","1704.52"],["2014-05","1630.88"],["2014-06","207.43"]]]
Use parseFloat(var) or parseInt(var) before passing data to the graph.
Where var is your variable or value which you are passing to graph.
I have a spreadsheet contains thousands of rows.
sometimes i wanna check the newest data by my smart phone ,
(the newest data always on the bottom)
if i open the sheet it spent me vary long time to scroll it to the bottom to see the latest data.
So,is there anyway to copy the last 10 or 30 data to another sheet automatically , so i can save mytime ?
many thanks for helping my problem, thank you!
Hi i can tell you how to reverse the data we fetch. To reverse the order of the data we receive from the spreadsheet can be done using the following procedure.
What you need to do,, find following function, inside your functions file. like in my case in am using GoogleSheet.php
private function findRows($search=FALSE)
It should look like this:
private function findRows($search=FALSE)
{
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($this->getSpreadsheetId());
$query->setWorksheetId($this->getWorksheetId());
and add
$query->setReverse('true');
line after
$query->setWorksheetId($this->getWorksheetId());
This will reverse the order of data you will fetch.
i hope this will help you for reversing the data you receive.
thank you.