Module talk:SportsRankings
Updating data
Hi Jts1882, Just wondering if there's any protocol or consensus already in place for updating all the ranking data? I see that the November rankings were released, but the Module:SportsRankings/data/FIFA World Rankings page still has the data from October. Is this something that you'll be maintaining as author of the module data? Or is there a quick way to pull the data from FIFA (etc) and repopulate the data so that someone else can do it if they notice its out of date? --Philk84
12:07, 4 December 2018 (UTC)
- @Philk84: I hadn't really thought about it. I can do it, but the the more people who can make the updates the better. Do you want to volunteer and I'll talk you through it?
- I have an Excel file where I copy the data and use a formula to generate the appropriate lines. If the rank is in column A, teams in column B, ... points in colume E, then this formula should work:
=CONCAT(" { '", B11, "', ",A11,", ",E11,", ",LEFT(C11,FIND("(",C11)-1)," }, ")
- Then it just needs copying into the rankings section of the data. The name in the Ivory Coast entry also needs to be change to { "Côte d'Ivoire", xx, x, xxxx }, as unfortunately Excel only allows double quotes in strings.
- If you don't have time, let me know and I'll make the changes. Jts1882 | talk 12:38, 4 December 2018 (UTC)
- I don't have time at the moment (end of year deadlines in 'the real world'), but it could be something I can look into sporadically next year. How do you get the data into Excel? Does FIFA give an export somewhere? --Philk84
12:50, 4 December 2018 (UTC)
- I just copy and paste table from their rankings page. I'll make the changes. I note they have changed the format of the table so it will need a different formula. Jts1882 | talk 12:54, 4 December 2018 (UTC)
- Not sure if it would help, but as a starting point I made a quick JavaScript function that you could use, rather than having to copy everything to Excel: https://jsfiddle.net/yux387b2/ copy the JS, open the console on the FIFA page (F12 in Chrome) and paste the JS and run it (enter). It will then output the table in a similar format to what you need for the data. Next time I find some spare time, I'll try to make it grab all pages rather than just the one you're on, as at the moment you'd need to combine 5 sets of console outputs into one. I can also see about a code version of the list (FRA instead of France etc). Assuming this would be helpful? --Philk84
13:12, 4 December 2018 (UTC)
- Very useful. I didn't even know that was possible. You can also change your code to put the countries in double quotes and that allows "Côte d'Ivoire".
- The data module has a table of country names and codes, which is used for aliases when country code is used in
{{FIFA_World_Rankings/sandbox|CIV}}
(Output:This is the sandbox of SportsRankings. A sandbox is a subpage of a template or article used to test a change to the main article or template before deploying said changes. Once you have finished with the test, please erase the contents of this page leaving this box ({{Sandbox notice}}) in place. (diff)
See also: Main sandbox), although having it in the same data table might be useful in future. Jts1882 | talk 14:04, 4 December 2018 (UTC)
- Try https://jsfiddle.net/philipbkemp/sorhxqg2/2/. You'll need to copy the JS into the console, then type
pullData()
, change page, typepullData()
again (repeating until you've called pullData() on each page). Then, useprintData()
to get all data, in both formats, displayed in the console output. I tried to get it to paginate automatically, but it's a bit tricky as the next page data only comes at a random time later. Hopefully this should be enough for now and you can copy/paste the output into the data file. Can you take a look and let me know if this sufficient? When I find a few spare minutes here and there, I'll see about making scripts for similar Sports Rankings datasets. --Philk8410:08, 5 December 2018 (UTC)
- Try https://jsfiddle.net/philipbkemp/sorhxqg2/2/. You'll need to copy the JS into the console, then type
References
- Not sure if it would help, but as a starting point I made a quick JavaScript function that you could use, rather than having to copy everything to Excel: https://jsfiddle.net/yux387b2/ copy the JS, open the console on the FIFA page (F12 in Chrome) and paste the JS and run it (enter). It will then output the table in a similar format to what you need for the data. Next time I find some spare time, I'll try to make it grab all pages rather than just the one you're on, as at the moment you'd need to combine 5 sets of console outputs into one. I can also see about a code version of the list (FRA instead of France etc). Assuming this would be helpful? --Philk84
- I just copy and paste table from their rankings page. I'll make the changes. I note they have changed the format of the table so it will need a different formula. Jts1882 | talk 12:54, 4 December 2018 (UTC)
- I don't have time at the moment (end of year deadlines in 'the real world'), but it could be something I can look into sporadically next year. How do you get the data into Excel? Does FIFA give an export somewhere? --Philk84