Site
Home / Forum / General Discussion / [Request] Script to create tennis events

[Request] Script to create tennis events


Posted: 06 Feb 2021 11:42

Ovokx
Posts: 1,700
Joined: 2020-06-17

Hi curswine,

Is is possible that you create an script similar than the ones you made to add stats & thumb to add tennis events, please? I have found a database for events from 2000 up to now for ATP and 2007 up to now for WTA and it will be very helpfull.

TY!

zag
Posted: 06 Feb 2021 12:07
curswine
Posts: 869
Joined: 2020-06-17

I just need to get some more details, but sounds like something that should be possible.

Can you send the source to me so that I can see how the data is listed?

Hopefully I can make a Python script that will write a CSV file from the source data and then have that read into TSDB as an event.

Ovokx
Posted: 06 Feb 2021 12:19

Ovokx
Posts: 1,700
Joined: 2020-06-17

Sure! Data could be downloaded from here: https://tennis-data.co.uk/alldata.php

Tennis event titles are currently added to the db by using this structure:

"Tournament name" - "Surname Player 1" vs "Surname Player 2"

Example: Antalya Open - Bublik vs De Minaur

TY!

Posted: 06 Feb 2021 16:36
curswine
Posts: 869
Joined: 2020-06-17

I've had a look and it should be possible to create something with the files on that site.

A couple of problems I can see that will be encountered:
- There is no country information included, without creating a lookup of every city in the world I can't really think of a way to include it.
- There is no time data for the event time, these will all display as 00:00:00.
- All event names themselves will be spoilers as they will be displayed as 'winner vs loser'. edit: I will see if I can implement something where the higher ranked player is listed first as that data is included.

One question, should the number in the ATP column be used as the round number?

I'll try and get something made as soon as I can, but please bear with me as I'm still learning how to do this.

Posted: 06 Feb 2021 18:47

zag
Posts: 3,329
Joined: 2020-03-23

Really nice find that data!

Let me know if you need anything changed on the site to add them automatically.

EDIT: Looking at the data it would be cool to get the result in the event result description field as well.

EDIT2: shame it doesn't include the first name of the player.

Posted: 06 Feb 2021 18:49

Ovokx
Posts: 1,700
Joined: 2020-06-17

- There is no time data for the event time, these will all display as 00:00:00.

There's another source where times are displayed (UTC +2) which was the one I used to manually upload events, but some events are missing: https://tennis.wettpoint.com/en/atp-tour.html


- All event names themselves will be spoilers as they will be displayed as 'winner vs loser'. edit: I will see if I can implement something where the higher ranked player is listed first as that data is included.


Currently if you check the seasons, you will also see spoilers, but I think it can be a good idea to display them by rank


One question, should the number in the ATP column be used as the round number?


Yes, ATP column must be used as round number, as we have all ATP and WTA events grouped by tiers, instead of by events.


Thanks for your time on this!

Posted: 06 Feb 2021 22:16
curswine
Posts: 869
Joined: 2020-06-17

Let me know if you need anything changed on the site to add them automatically.

I shouldn't need anything, but be prepared to see some deleted events when I inevitably make a mistake.

There's another source where times are displayed (UTC +2) which was the one I used to manually upload events, but some events are missing: https://tennis.wettpoint.com/en/atp-tour.html

It'll be way past my ability to get the two synced up I'm afraid. They'll have to be manually entered, or a default time can be set across all matches.

I've actually made quite a bit of progress and should have it complete a lot sooner than I was expecting. What is your preference for how the description and result box should be filled out?

This is what I currently have:




Posted: 07 Feb 2021 08:56

Ovokx
Posts: 1,700
Joined: 2020-06-17

I've actually made quite a bit of progress and should have it complete a lot sooner than I was expecting. What is your preference for how the description and result box should be filled out?

This is what I currently have:




I would choose the second one

@zag, I think it would be great to implement this as we'll have now a great tennis db:

https://trello.com/c/uwZ0ZjFS/21-tennis-results



zag
Posted: 07 Feb 2021 09:17
curswine
Posts: 869
Joined: 2020-06-17

I would choose the second one

I didn't mean that as a choice between the two, I mean how would you prefer the description and result box to be formated? IE do you want it to show the court type (outdoor, indoor), court surface (hard, clay, grass) and how should I display that.

Posted: 08 Feb 2021 21:51
curswine
Posts: 869
Joined: 2020-06-17

I'm so close to completing it, I just have a problem with getting the higher ranked player to appear first in the event title, For the life of me I can't work out where I'm going wrong.

Also do you have any feedback on how the data in the description and result box is being presented?

I have been testing with these events here https://www.thesportsdb.com/season.php?l=4464&s=2011

Posted: 08 Feb 2021 22:11
curswine
Posts: 869
Joined: 2020-06-17

If somebody wants to take a look here is the code: https://controlc.com/2ff26a38

The problem is lines 225 to 236, I just can't make the higher ranked player appear first in the event title.

Posted: 09 Feb 2021 19:24

Ovokx
Posts: 1,700
Joined: 2020-06-17


I have been testing with these events here https://www.thesportsdb.com/season.php?l=4464&s=2011


There's no events for that season

Posted: 09 Feb 2021 20:07
curswine
Posts: 869
Joined: 2020-06-17


I have been testing with these events here https://www.thesportsdb.com/season.php?l=4464&s=2011

There's no events for that season


Sorry I deleted them to test the script. I think it is working correctly now.

I've added them again, tell me what changes you want to see, and then I'll post the completed script for you to use.

Posted: 09 Feb 2021 21:37

zag
Posts: 3,329
Joined: 2020-03-23

If somebody wants to take a look here is the code: https://controlc.com/2ff26a38

The problem is lines 225 to 236, I just can't make the higher ranked player appear first in the event title.


Code looks good to me with my limited python abilities, one thing I would check is that they are an integer so the "more than" will work. If its a string then the code wont understand the difference.

You could also just choose a random player with a list random sort.

Posted: 09 Feb 2021 21:44
curswine
Posts: 869
Joined: 2020-06-17

If somebody wants to take a look here is the code: https://controlc.com/2ff26a38

The problem is lines 225 to 236, I just can't make the higher ranked player appear first in the event title.

Code looks good to me with my limited python abilities, one thing I would check is that they are an integer so the "more than" will work. If its a string then the code wont understand the difference.

You could also just choose a random player with a list random sort.


I posted it to stackoverflow and they suggested the exact same thing, now it works fine.

I just need to test it on a larger number of matches to make sure it doesn't go too fast and miss the edit button.

zag
Posted: 10 Feb 2021 12:28

Ovokx
Posts: 1,700
Joined: 2020-06-17


I have been testing with these events here https://www.thesportsdb.com/season.php?l=4464&s=2011

There's no events for that season

Sorry I deleted them to test the script. I think it is working correctly now.

I've added them again, tell me what changes you want to see, and then I'll post the completed script for you to use.


Looks perfect for me. The only difference with the current ones is that the "-" is missing between event name and first player surname.

Amazing job!

Posted: 10 Feb 2021 14:02

zag
Posts: 3,329
Joined: 2020-03-23

Assuming it stays in a standard format, I might even be able to script up something to add the indivudal player 'Result List' as well (using the event result description text).

One thing for that to happen would need to have the players in our database so I will leave that to others.

Posted: 10 Feb 2021 14:34
curswine
Posts: 869
Joined: 2020-06-17

Looks perfect for me. The only difference with the current ones is that the "-" is missing between event name and first player surname.

Amazing job!


Great, I will change that and test adding whole tournaments before I publish the completed script.

Assuming it stays in a standard format, I might even be able to script up something to add the indivudal player 'Result List' as well (using the event result description text).

One thing for that to happen would need to have the players in our database so I will leave that to others.


I already have something like that made to post sumo results, the tricky thing would be ensuring all names are 100% accurate and the same so that the right player is selected and I don't think that would be possible seeing as this data only has surnames.

But I'm sure a work around could be found.

Posted: 10 Feb 2021 18:32
curswine
Posts: 869
Joined: 2020-06-17

I've encountered one small bug I need to iron out, I didn't take into account that some players might be unranked and that threw up and error.

Other than that it worked great and I've managed to add every men's Grand Slam match (except one) of 2011.

Ovokx, zag
Posted: 10 Feb 2021 20:47

zag
Posts: 3,329
Joined: 2020-03-23

There is one small thing where the apsotrophe's are escaped with a backslash. Its not a big deal as I can fix on the database side once your done but I thought I would mention it.

Maybe just remove any apostrophes before the script submits?

I also wonder if we should clean up the existing events, but of course this can also be done after.

curswine
Posted: 10 Feb 2021 21:13
curswine
Posts: 869
Joined: 2020-06-17

There is one small thing where the apsotrophe's are escaped with a backslash. Its not a big deal as I can fix on the database side once your done but I thought I would mention it.

Maybe just remove any apostrophes before the script submits?

I also wonder if we should clean up the existing events, but of course this can also be done after.


I just left the script running while I did some other stuff as I thought it was going well, but I've noticed a few characters not being displayed properly as well as the apostrophe problem you pointed out.

The apostrophes can be parsed out in the the code, but I need to see what settings the .csv file needs to be saved as to display some of the characters that are being missed.



Posted: 10 Feb 2021 21:22

zag
Posts: 3,329
Joined: 2020-03-23

There is one small thing where the apsotrophe's are escaped with a backslash. Its not a big deal as I can fix on the database side once your done but I thought I would mention it.

Maybe just remove any apostrophes before the script submits?

I also wonder if we should clean up the existing events, but of course this can also be done after.

I just left the script running while I did some other stuff as I thought it was going well, but I've noticed a few characters not being displayed properly as well as the apostrophe problem you pointed out.

The apostrophes can be parsed out in the the code, but I need to see what settings the .csv file needs to be saved as to display some of the characters that are being missed.



UTF8 generally, notepad++ can encode it nicely. Saying that special characters can be a nightmare as they get translated in python and all sorts.

Personally I would save the bother and just do a quick search and replace on the csv to change them before importing to the English equivalent letter


Posted: 10 Feb 2021 21:55
curswine
Posts: 869
Joined: 2020-06-17

UTF8 generally, notepad++ can encode it nicely. Saying that special characters can be a nightmare as they get translated in python and all sorts.

Personally I would save the bother and just do a quick search and replace on the csv to change them before importing to the English equivalent letter


Usually I would do exactly that as I've had trouble with special characters and CSV files in Photoshop before and I found Notepad++ to be great at saving as UTF8. Didn't cross my mind to do it for this too ...

I've added a couple of .replace("'", "") hopefully that will stop it for the most part.


Posted: 11 Feb 2021 11:38

zag
Posts: 3,329
Joined: 2020-03-23

Cool just let me know if you need anything bulk deleted

Posted: 07 Apr 2021 14:35
curswine
Posts: 869
Joined: 2020-06-17

Here is the script I've come up with. https://drive.google.com/file/d/1Wz2Zq1nCmC1-koMyHZ3NAcy-NOo8ZaUl/view?usp=sharing

It's not as quick as I would've hoped, but better than adding manually.

Please read the comments in the script for where to put your username, password etc.

You'll need to wait for round numbers above 50 to be added before being able to add whole years, even with the script that could take 1 hour+ to add.

Ovokx

Who is Online?

In total there are 68 users online :: 3 registered, 0 hidden and 65 guests (based on users active over the past 5 minutes) Most users ever online was 424 on Fri Nov 10, 2017 9:02 pm

About Us

Discussion forum for TheSportsDB.com site and related topics

Rules

- Be Polite
- Respect other users
- Always post log files with issues
- Try to be helpful
- No Piracy discussion

Showing 0 to 25 (Total: 28)