datafc 1.0.0__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datafc-1.0.0 → datafc-1.1.0}/PKG-INFO +19 -7
- {datafc-1.0.0 → datafc-1.1.0}/README.md +18 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_coordinates_data.py +2 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_goal_networks_data.py +2 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_lineups_data.py +2 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_match_data.py +6 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_match_odds_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_match_stats_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_momentum_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_shots_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_standings_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/fetch_substitutions_data.py +8 -6
- {datafc-1.0.0 → datafc-1.1.0}/datafc/utils/_save_files.py +8 -8
- {datafc-1.0.0 → datafc-1.1.0}/datafc.egg-info/PKG-INFO +19 -7
- {datafc-1.0.0 → datafc-1.1.0}/setup.py +1 -1
- {datafc-1.0.0 → datafc-1.1.0}/LICENSE +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/__init__.py +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/sofascore/__init__.py +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/utils/__init__.py +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/utils/_config.py +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc/utils/_setup_webdriver.py +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc.egg-info/SOURCES.txt +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc.egg-info/dependency_links.txt +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc.egg-info/requires.txt +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/datafc.egg-info/top_level.txt +0 -0
- {datafc-1.0.0 → datafc-1.1.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datafc
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A scalable Python library for fetching, processing, and exporting structured football match data.
|
|
5
5
|
Home-page: https://github.com/urazakgul/datafc
|
|
6
6
|
Author: Uraz Akgül
|
|
@@ -14,7 +14,7 @@ Requires-Python: >=3.8
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
|
|
17
|
-
# datafc v1.
|
|
17
|
+
# datafc v1.1.0
|
|
18
18
|
|
|
19
19
|
## Overview
|
|
20
20
|
|
|
@@ -53,7 +53,13 @@ pip install git+https://github.com/urazakgul/datafc.git
|
|
|
53
53
|
To install a specific version of `datafc`, use:
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
pip install datafc==1.
|
|
56
|
+
pip install datafc==1.1.0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If you already have `datafc` installed and want to upgrade to the latest version, run:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install --upgrade datafc
|
|
57
63
|
```
|
|
58
64
|
|
|
59
65
|
## Why Selenium?
|
|
@@ -142,7 +148,7 @@ Unlike the other functions, `standings_data` does not require `match_data` or `l
|
|
|
142
148
|
|
|
143
149
|
#### `match_data`
|
|
144
150
|
|
|
145
|
-
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, away team, start timestamp, and match status.
|
|
151
|
+
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, home team ID, away team, away team ID, added injury times for both halves, start timestamp, and match status.
|
|
146
152
|
|
|
147
153
|
Example Usage:
|
|
148
154
|
|
|
@@ -180,7 +186,11 @@ The returned DataFrame includes the following columns:
|
|
|
180
186
|
* `week`: The matchweek number.
|
|
181
187
|
* `game_id`: The unique identifier for the match.
|
|
182
188
|
* `home_team`: The name of the home team.
|
|
189
|
+
* `home_team_id`: The unique identifier for the home team.
|
|
183
190
|
* `away_team`: The name of the away team.
|
|
191
|
+
* `away_team_id`: The unique identifier for the away team.
|
|
192
|
+
* `injury_time_1`: Added injury time in the first half.
|
|
193
|
+
* `injury_time_2`: Added injury time in the second half.
|
|
184
194
|
* `start_timestamp`: The start time of the match.
|
|
185
195
|
* `status`: The current status of the match.
|
|
186
196
|
|
|
@@ -638,14 +648,16 @@ Dependencies:
|
|
|
638
648
|
|
|
639
649
|
## Changelog
|
|
640
650
|
|
|
641
|
-
*
|
|
651
|
+
* v1.1.0
|
|
652
|
+
* Added 4 new columns to `match_data`
|
|
653
|
+
* Added `data_source` parameter to `save_json` and `save_excel` for including the source in file names
|
|
654
|
+
|
|
655
|
+
* v1.0.0
|
|
642
656
|
* Initial release of `datafc`
|
|
643
657
|
* Fetching match data using Selenium WebDriver
|
|
644
658
|
* Supports Sofascore as a data source
|
|
645
659
|
* Exports data in JSON and Excel formats
|
|
646
660
|
|
|
647
|
-
Future releases will include additional features and bug fixes.
|
|
648
|
-
|
|
649
661
|
## License
|
|
650
662
|
|
|
651
663
|
This project is open-source and licensed under the MIT License.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# datafc v1.
|
|
1
|
+
# datafc v1.1.0
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
@@ -37,7 +37,13 @@ pip install git+https://github.com/urazakgul/datafc.git
|
|
|
37
37
|
To install a specific version of `datafc`, use:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
pip install datafc==1.
|
|
40
|
+
pip install datafc==1.1.0
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you already have `datafc` installed and want to upgrade to the latest version, run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install --upgrade datafc
|
|
41
47
|
```
|
|
42
48
|
|
|
43
49
|
## Why Selenium?
|
|
@@ -126,7 +132,7 @@ Unlike the other functions, `standings_data` does not require `match_data` or `l
|
|
|
126
132
|
|
|
127
133
|
#### `match_data`
|
|
128
134
|
|
|
129
|
-
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, away team, start timestamp, and match status.
|
|
135
|
+
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, home team ID, away team, away team ID, added injury times for both halves, start timestamp, and match status.
|
|
130
136
|
|
|
131
137
|
Example Usage:
|
|
132
138
|
|
|
@@ -164,7 +170,11 @@ The returned DataFrame includes the following columns:
|
|
|
164
170
|
* `week`: The matchweek number.
|
|
165
171
|
* `game_id`: The unique identifier for the match.
|
|
166
172
|
* `home_team`: The name of the home team.
|
|
173
|
+
* `home_team_id`: The unique identifier for the home team.
|
|
167
174
|
* `away_team`: The name of the away team.
|
|
175
|
+
* `away_team_id`: The unique identifier for the away team.
|
|
176
|
+
* `injury_time_1`: Added injury time in the first half.
|
|
177
|
+
* `injury_time_2`: Added injury time in the second half.
|
|
168
178
|
* `start_timestamp`: The start time of the match.
|
|
169
179
|
* `status`: The current status of the match.
|
|
170
180
|
|
|
@@ -622,14 +632,16 @@ Dependencies:
|
|
|
622
632
|
|
|
623
633
|
## Changelog
|
|
624
634
|
|
|
625
|
-
*
|
|
635
|
+
* v1.1.0
|
|
636
|
+
* Added 4 new columns to `match_data`
|
|
637
|
+
* Added `data_source` parameter to `save_json` and `save_excel` for including the source in file names
|
|
638
|
+
|
|
639
|
+
* v1.0.0
|
|
626
640
|
* Initial release of `datafc`
|
|
627
641
|
* Fetching match data using Selenium WebDriver
|
|
628
642
|
* Supports Sofascore as a data source
|
|
629
643
|
* Exports data in JSON and Excel formats
|
|
630
644
|
|
|
631
|
-
Future releases will include additional features and bug fixes.
|
|
632
|
-
|
|
633
645
|
## License
|
|
634
646
|
|
|
635
647
|
This project is open-source and licensed under the MIT License.
|
|
@@ -89,6 +89,7 @@ def coordinates_data(
|
|
|
89
89
|
if enable_json_export:
|
|
90
90
|
save_json(
|
|
91
91
|
data=heatmap_df,
|
|
92
|
+
data_source=data_source,
|
|
92
93
|
country=first_row["country"],
|
|
93
94
|
tournament=first_row["tournament"],
|
|
94
95
|
season=first_row["season"],
|
|
@@ -98,6 +99,7 @@ def coordinates_data(
|
|
|
98
99
|
if enable_excel_export:
|
|
99
100
|
save_excel(
|
|
100
101
|
data=heatmap_df,
|
|
102
|
+
data_source=data_source,
|
|
101
103
|
country=first_row["country"],
|
|
102
104
|
tournament=first_row["tournament"],
|
|
103
105
|
season=first_row["season"],
|
|
@@ -124,6 +124,7 @@ def goal_networks_data(
|
|
|
124
124
|
if enable_json_export:
|
|
125
125
|
save_json(
|
|
126
126
|
data=actions_list_df,
|
|
127
|
+
data_source=data_source,
|
|
127
128
|
country=first_row["country"],
|
|
128
129
|
tournament=first_row["tournament"],
|
|
129
130
|
season=first_row["season"],
|
|
@@ -133,6 +134,7 @@ def goal_networks_data(
|
|
|
133
134
|
if enable_excel_export:
|
|
134
135
|
save_excel(
|
|
135
136
|
data=actions_list_df,
|
|
137
|
+
data_source=data_source,
|
|
136
138
|
country=first_row["country"],
|
|
137
139
|
tournament=first_row["tournament"],
|
|
138
140
|
season=first_row["season"],
|
|
@@ -119,6 +119,7 @@ def lineups_data(
|
|
|
119
119
|
if enable_json_export:
|
|
120
120
|
save_json(
|
|
121
121
|
data=extracted_lineups_data_df,
|
|
122
|
+
data_source=data_source,
|
|
122
123
|
country=first_row["country"],
|
|
123
124
|
tournament=first_row["tournament"],
|
|
124
125
|
season=first_row["season"],
|
|
@@ -128,6 +129,7 @@ def lineups_data(
|
|
|
128
129
|
if enable_excel_export:
|
|
129
130
|
save_excel(
|
|
130
131
|
data=extracted_lineups_data_df,
|
|
132
|
+
data_source=data_source,
|
|
131
133
|
country=first_row["country"],
|
|
132
134
|
tournament=first_row["tournament"],
|
|
133
135
|
season=first_row["season"],
|
|
@@ -60,7 +60,11 @@ def match_data(
|
|
|
60
60
|
"week": events_df["roundInfo"].apply(lambda x: x.get("round", "")),
|
|
61
61
|
"game_id": events_df["id"],
|
|
62
62
|
"home_team": events_df["homeTeam"].apply(lambda x: x.get("name", "")),
|
|
63
|
+
"home_team_id": events_df["homeTeam"].apply(lambda x: x.get("id", "")),
|
|
63
64
|
"away_team": events_df["awayTeam"].apply(lambda x: x.get("name", "")),
|
|
65
|
+
"away_team_id": events_df["awayTeam"].apply(lambda x: x.get("id", "")),
|
|
66
|
+
"injury_time_1": events_df["time"].apply(lambda x: x.get("injuryTime1", "")),
|
|
67
|
+
"injury_time_2": events_df["time"].apply(lambda x: x.get("injuryTime2", "")),
|
|
64
68
|
"start_timestamp": events_df["startTimestamp"],
|
|
65
69
|
"status": events_df["status"].apply(lambda x: x.get("description", ""))
|
|
66
70
|
})
|
|
@@ -71,6 +75,7 @@ def match_data(
|
|
|
71
75
|
if enable_json_export:
|
|
72
76
|
save_json(
|
|
73
77
|
data=match_data_df,
|
|
78
|
+
data_source=data_source,
|
|
74
79
|
country=first_row["country"],
|
|
75
80
|
tournament=first_row["tournament"],
|
|
76
81
|
season=first_row["season"],
|
|
@@ -80,6 +85,7 @@ def match_data(
|
|
|
80
85
|
if enable_excel_export:
|
|
81
86
|
save_excel(
|
|
82
87
|
data=match_data_df,
|
|
88
|
+
data_source=data_source,
|
|
83
89
|
country=first_row["country"],
|
|
84
90
|
tournament=first_row["tournament"],
|
|
85
91
|
season=first_row["season"],
|
|
@@ -73,17 +73,18 @@ def match_odds_data(
|
|
|
73
73
|
except json.JSONDecodeError:
|
|
74
74
|
raise RuntimeError(f"Failed to decode odds data for game {game_id}.")
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
game_odds_df = pd.DataFrame(odds_list)
|
|
77
77
|
|
|
78
|
-
if
|
|
78
|
+
if game_odds_df.empty:
|
|
79
79
|
raise ValueError("No match odds data found for the specified parameters.")
|
|
80
80
|
|
|
81
81
|
if enable_json_export or enable_excel_export:
|
|
82
|
-
first_row =
|
|
82
|
+
first_row = game_odds_df.iloc[0]
|
|
83
83
|
|
|
84
84
|
if enable_json_export:
|
|
85
85
|
save_json(
|
|
86
|
-
data=
|
|
86
|
+
data=game_odds_df,
|
|
87
|
+
data_source=data_source,
|
|
87
88
|
country=first_row["country"],
|
|
88
89
|
tournament=first_row["tournament"],
|
|
89
90
|
season=first_row["season"],
|
|
@@ -92,14 +93,15 @@ def match_odds_data(
|
|
|
92
93
|
|
|
93
94
|
if enable_excel_export:
|
|
94
95
|
save_excel(
|
|
95
|
-
data=
|
|
96
|
+
data=game_odds_df,
|
|
97
|
+
data_source=data_source,
|
|
96
98
|
country=first_row["country"],
|
|
97
99
|
tournament=first_row["tournament"],
|
|
98
100
|
season=first_row["season"],
|
|
99
101
|
week_number=first_row["week"]
|
|
100
102
|
)
|
|
101
103
|
|
|
102
|
-
return
|
|
104
|
+
return game_odds_df
|
|
103
105
|
|
|
104
106
|
except WebDriverException as e:
|
|
105
107
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -71,17 +71,18 @@ def match_stats_data(
|
|
|
71
71
|
except json.JSONDecodeError:
|
|
72
72
|
raise RuntimeError(f"Failed to decode match statistics for game {game_id}.")
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
game_statistics_df = pd.DataFrame(statistics_list)
|
|
75
75
|
|
|
76
|
-
if
|
|
76
|
+
if game_statistics_df.empty:
|
|
77
77
|
raise ValueError("No match statistics data found for the specified parameters.")
|
|
78
78
|
|
|
79
79
|
if enable_json_export or enable_excel_export:
|
|
80
|
-
first_row =
|
|
80
|
+
first_row = game_statistics_df.iloc[0]
|
|
81
81
|
|
|
82
82
|
if enable_json_export:
|
|
83
83
|
save_json(
|
|
84
|
-
data=
|
|
84
|
+
data=game_statistics_df,
|
|
85
|
+
data_source=data_source,
|
|
85
86
|
country=first_row["country"],
|
|
86
87
|
tournament=first_row["tournament"],
|
|
87
88
|
season=first_row["season"],
|
|
@@ -90,14 +91,15 @@ def match_stats_data(
|
|
|
90
91
|
|
|
91
92
|
if enable_excel_export:
|
|
92
93
|
save_excel(
|
|
93
|
-
data=
|
|
94
|
+
data=game_statistics_df,
|
|
95
|
+
data_source=data_source,
|
|
94
96
|
country=first_row["country"],
|
|
95
97
|
tournament=first_row["tournament"],
|
|
96
98
|
season=first_row["season"],
|
|
97
99
|
week_number=first_row["week"]
|
|
98
100
|
)
|
|
99
101
|
|
|
100
|
-
return
|
|
102
|
+
return game_statistics_df
|
|
101
103
|
|
|
102
104
|
except WebDriverException as e:
|
|
103
105
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -66,17 +66,18 @@ def momentum_data(
|
|
|
66
66
|
except json.JSONDecodeError:
|
|
67
67
|
raise RuntimeError(f"Failed to decode momentum data for game {game_id}.")
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
momentum_df = pd.DataFrame(momentum_list)
|
|
70
70
|
|
|
71
|
-
if
|
|
71
|
+
if momentum_df.empty:
|
|
72
72
|
raise ValueError("No momentum data found for the specified parameters.")
|
|
73
73
|
|
|
74
74
|
if enable_json_export or enable_excel_export:
|
|
75
|
-
first_row =
|
|
75
|
+
first_row = momentum_df.iloc[0]
|
|
76
76
|
|
|
77
77
|
if enable_json_export:
|
|
78
78
|
save_json(
|
|
79
|
-
data=
|
|
79
|
+
data=momentum_df,
|
|
80
|
+
data_source=data_source,
|
|
80
81
|
country=first_row["country"],
|
|
81
82
|
tournament=first_row["tournament"],
|
|
82
83
|
season=first_row["season"],
|
|
@@ -85,14 +86,15 @@ def momentum_data(
|
|
|
85
86
|
|
|
86
87
|
if enable_excel_export:
|
|
87
88
|
save_excel(
|
|
88
|
-
data=
|
|
89
|
+
data=momentum_df,
|
|
90
|
+
data_source=data_source,
|
|
89
91
|
country=first_row["country"],
|
|
90
92
|
tournament=first_row["tournament"],
|
|
91
93
|
season=first_row["season"],
|
|
92
94
|
week_number=first_row["week"]
|
|
93
95
|
)
|
|
94
96
|
|
|
95
|
-
return
|
|
97
|
+
return momentum_df
|
|
96
98
|
|
|
97
99
|
except WebDriverException as e:
|
|
98
100
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -102,17 +102,18 @@ def shots_data(
|
|
|
102
102
|
except json.JSONDecodeError:
|
|
103
103
|
raise RuntimeError(f"Failed to decode shot data for game {game_id}.")
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
shotmap_df = pd.DataFrame(shotmap_list)
|
|
106
106
|
|
|
107
|
-
if
|
|
107
|
+
if shotmap_df.empty:
|
|
108
108
|
raise ValueError("No shot data found for the specified parameters.")
|
|
109
109
|
|
|
110
110
|
if enable_json_export or enable_excel_export:
|
|
111
|
-
first_row =
|
|
111
|
+
first_row = shotmap_df.iloc[0]
|
|
112
112
|
|
|
113
113
|
if enable_json_export:
|
|
114
114
|
save_json(
|
|
115
|
-
data=
|
|
115
|
+
data=shotmap_df,
|
|
116
|
+
data_source=data_source,
|
|
116
117
|
country=first_row["country"],
|
|
117
118
|
tournament=first_row["tournament"],
|
|
118
119
|
season=first_row["season"],
|
|
@@ -121,14 +122,15 @@ def shots_data(
|
|
|
121
122
|
|
|
122
123
|
if enable_excel_export:
|
|
123
124
|
save_excel(
|
|
124
|
-
data=
|
|
125
|
+
data=shotmap_df,
|
|
126
|
+
data_source=data_source,
|
|
125
127
|
country=first_row["country"],
|
|
126
128
|
tournament=first_row["tournament"],
|
|
127
129
|
season=first_row["season"],
|
|
128
130
|
week_number=first_row["week"]
|
|
129
131
|
)
|
|
130
132
|
|
|
131
|
-
return
|
|
133
|
+
return shotmap_df
|
|
132
134
|
|
|
133
135
|
except WebDriverException as e:
|
|
134
136
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -70,17 +70,18 @@ def standings_data(
|
|
|
70
70
|
except json.JSONDecodeError:
|
|
71
71
|
raise RuntimeError(f"Failed to decode standings data for category {category}.")
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
points_table_df = pd.DataFrame(points_table_list)
|
|
74
74
|
|
|
75
|
-
if
|
|
75
|
+
if points_table_df.empty:
|
|
76
76
|
raise ValueError("No standings data found for the specified parameters.")
|
|
77
77
|
|
|
78
78
|
if enable_json_export or enable_excel_export:
|
|
79
|
-
first_row =
|
|
79
|
+
first_row = points_table_df.iloc[0]
|
|
80
80
|
|
|
81
81
|
if enable_json_export:
|
|
82
82
|
save_json(
|
|
83
|
-
data=
|
|
83
|
+
data=points_table_df,
|
|
84
|
+
data_source=data_source,
|
|
84
85
|
country=first_row["country"],
|
|
85
86
|
tournament=first_row["tournament"],
|
|
86
87
|
season=None,
|
|
@@ -89,14 +90,15 @@ def standings_data(
|
|
|
89
90
|
|
|
90
91
|
if enable_excel_export:
|
|
91
92
|
save_excel(
|
|
92
|
-
data=
|
|
93
|
+
data=points_table_df,
|
|
94
|
+
data_source=data_source,
|
|
93
95
|
country=first_row["country"],
|
|
94
96
|
tournament=first_row["tournament"],
|
|
95
97
|
season=None,
|
|
96
98
|
week_number=None
|
|
97
99
|
)
|
|
98
100
|
|
|
99
|
-
return
|
|
101
|
+
return points_table_df
|
|
100
102
|
|
|
101
103
|
except WebDriverException as e:
|
|
102
104
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -70,17 +70,18 @@ def substitutions_data(
|
|
|
70
70
|
except json.JSONDecodeError:
|
|
71
71
|
raise RuntimeError(f"Failed to decode substitution data for game {game_id}.")
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
substitutions_df = pd.DataFrame(substitutions_list)
|
|
74
74
|
|
|
75
|
-
if
|
|
75
|
+
if substitutions_df.empty:
|
|
76
76
|
raise ValueError("No substitution data found for the specified parameters.")
|
|
77
77
|
|
|
78
78
|
if enable_json_export or enable_excel_export:
|
|
79
|
-
first_row =
|
|
79
|
+
first_row = substitutions_df.iloc[0]
|
|
80
80
|
|
|
81
81
|
if enable_json_export:
|
|
82
82
|
save_json(
|
|
83
|
-
data=
|
|
83
|
+
data=substitutions_df,
|
|
84
|
+
data_source=data_source,
|
|
84
85
|
country=first_row["country"],
|
|
85
86
|
tournament=first_row["tournament"],
|
|
86
87
|
season=first_row["season"],
|
|
@@ -89,14 +90,15 @@ def substitutions_data(
|
|
|
89
90
|
|
|
90
91
|
if enable_excel_export:
|
|
91
92
|
save_excel(
|
|
92
|
-
data=
|
|
93
|
+
data=substitutions_df,
|
|
94
|
+
data_source=data_source,
|
|
93
95
|
country=first_row["country"],
|
|
94
96
|
tournament=first_row["tournament"],
|
|
95
97
|
season=first_row["season"],
|
|
96
98
|
week_number=first_row["week"]
|
|
97
99
|
)
|
|
98
100
|
|
|
99
|
-
return
|
|
101
|
+
return substitutions_df
|
|
100
102
|
|
|
101
103
|
except WebDriverException as e:
|
|
102
104
|
raise RuntimeError(f"Selenium WebDriver error: {str(e)}")
|
|
@@ -2,7 +2,7 @@ import json
|
|
|
2
2
|
import pandas as pd
|
|
3
3
|
import inspect
|
|
4
4
|
|
|
5
|
-
def save_json(data: pd.DataFrame, country: str, tournament: int, season: int = None, week_number: int = None) -> None:
|
|
5
|
+
def save_json(data: pd.DataFrame, data_source: str, country: str, tournament: int, season: int = None, week_number: int = None) -> None:
|
|
6
6
|
calling_function = inspect.stack()[1].function
|
|
7
7
|
|
|
8
8
|
country = country.lower().replace(" ", "_")
|
|
@@ -13,11 +13,11 @@ def save_json(data: pd.DataFrame, country: str, tournament: int, season: int = N
|
|
|
13
13
|
season = season.replace("/", "")
|
|
14
14
|
|
|
15
15
|
if season is not None and week_number is not None:
|
|
16
|
-
file_name = f"{country}_{tournament}_{season}_{week_number}_{calling_function}.json"
|
|
16
|
+
file_name = f"{data_source}_{country}_{tournament}_{season}_{week_number}_{calling_function}.json"
|
|
17
17
|
elif season is not None:
|
|
18
|
-
file_name = f"{country}_{tournament}_{season}_{calling_function}.json"
|
|
18
|
+
file_name = f"{data_source}_{country}_{tournament}_{season}_{calling_function}.json"
|
|
19
19
|
else:
|
|
20
|
-
file_name = f"{country}_{tournament}_{calling_function}.json"
|
|
20
|
+
file_name = f"{data_source}_{country}_{tournament}_{calling_function}.json"
|
|
21
21
|
|
|
22
22
|
try:
|
|
23
23
|
with open(file_name, "w", encoding="utf-8") as json_file:
|
|
@@ -26,7 +26,7 @@ def save_json(data: pd.DataFrame, country: str, tournament: int, season: int = N
|
|
|
26
26
|
except Exception as e:
|
|
27
27
|
print(f"Error saving JSON: {e}")
|
|
28
28
|
|
|
29
|
-
def save_excel(data: pd.DataFrame, country: str, tournament: int, season: int = None, week_number: int = None) -> None:
|
|
29
|
+
def save_excel(data: pd.DataFrame, data_source: str, country: str, tournament: int, season: int = None, week_number: int = None) -> None:
|
|
30
30
|
calling_function = inspect.stack()[1].function
|
|
31
31
|
|
|
32
32
|
country = country.lower().replace(" ", "_")
|
|
@@ -37,11 +37,11 @@ def save_excel(data: pd.DataFrame, country: str, tournament: int, season: int =
|
|
|
37
37
|
season = season.replace("/", "")
|
|
38
38
|
|
|
39
39
|
if season is not None and week_number is not None:
|
|
40
|
-
file_name = f"{country}_{tournament}_{season}_{week_number}_{calling_function}.xlsx"
|
|
40
|
+
file_name = f"{data_source}_{country}_{tournament}_{season}_{week_number}_{calling_function}.xlsx"
|
|
41
41
|
elif season is not None:
|
|
42
|
-
file_name = f"{country}_{tournament}_{season}_{calling_function}.xlsx"
|
|
42
|
+
file_name = f"{data_source}_{country}_{tournament}_{season}_{calling_function}.xlsx"
|
|
43
43
|
else:
|
|
44
|
-
file_name = f"{country}_{tournament}_{calling_function}.xlsx"
|
|
44
|
+
file_name = f"{data_source}_{country}_{tournament}_{calling_function}.xlsx"
|
|
45
45
|
|
|
46
46
|
try:
|
|
47
47
|
data.to_excel(file_name, index=False)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datafc
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A scalable Python library for fetching, processing, and exporting structured football match data.
|
|
5
5
|
Home-page: https://github.com/urazakgul/datafc
|
|
6
6
|
Author: Uraz Akgül
|
|
@@ -14,7 +14,7 @@ Requires-Python: >=3.8
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
|
|
17
|
-
# datafc v1.
|
|
17
|
+
# datafc v1.1.0
|
|
18
18
|
|
|
19
19
|
## Overview
|
|
20
20
|
|
|
@@ -53,7 +53,13 @@ pip install git+https://github.com/urazakgul/datafc.git
|
|
|
53
53
|
To install a specific version of `datafc`, use:
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
pip install datafc==1.
|
|
56
|
+
pip install datafc==1.1.0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If you already have `datafc` installed and want to upgrade to the latest version, run:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install --upgrade datafc
|
|
57
63
|
```
|
|
58
64
|
|
|
59
65
|
## Why Selenium?
|
|
@@ -142,7 +148,7 @@ Unlike the other functions, `standings_data` does not require `match_data` or `l
|
|
|
142
148
|
|
|
143
149
|
#### `match_data`
|
|
144
150
|
|
|
145
|
-
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, away team, start timestamp, and match status.
|
|
151
|
+
The `match_data` function fetches match data for a specified tournament, season, and matchweek. It returns a DataFrame containing details such as country, tournament name, season, week number, game ID, home team, home team ID, away team, away team ID, added injury times for both halves, start timestamp, and match status.
|
|
146
152
|
|
|
147
153
|
Example Usage:
|
|
148
154
|
|
|
@@ -180,7 +186,11 @@ The returned DataFrame includes the following columns:
|
|
|
180
186
|
* `week`: The matchweek number.
|
|
181
187
|
* `game_id`: The unique identifier for the match.
|
|
182
188
|
* `home_team`: The name of the home team.
|
|
189
|
+
* `home_team_id`: The unique identifier for the home team.
|
|
183
190
|
* `away_team`: The name of the away team.
|
|
191
|
+
* `away_team_id`: The unique identifier for the away team.
|
|
192
|
+
* `injury_time_1`: Added injury time in the first half.
|
|
193
|
+
* `injury_time_2`: Added injury time in the second half.
|
|
184
194
|
* `start_timestamp`: The start time of the match.
|
|
185
195
|
* `status`: The current status of the match.
|
|
186
196
|
|
|
@@ -638,14 +648,16 @@ Dependencies:
|
|
|
638
648
|
|
|
639
649
|
## Changelog
|
|
640
650
|
|
|
641
|
-
*
|
|
651
|
+
* v1.1.0
|
|
652
|
+
* Added 4 new columns to `match_data`
|
|
653
|
+
* Added `data_source` parameter to `save_json` and `save_excel` for including the source in file names
|
|
654
|
+
|
|
655
|
+
* v1.0.0
|
|
642
656
|
* Initial release of `datafc`
|
|
643
657
|
* Fetching match data using Selenium WebDriver
|
|
644
658
|
* Supports Sofascore as a data source
|
|
645
659
|
* Exports data in JSON and Excel formats
|
|
646
660
|
|
|
647
|
-
Future releases will include additional features and bug fixes.
|
|
648
|
-
|
|
649
661
|
## License
|
|
650
662
|
|
|
651
663
|
This project is open-source and licensed under the MIT License.
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="datafc",
|
|
8
|
-
version="1.
|
|
8
|
+
version="1.1.0",
|
|
9
9
|
author="Uraz Akgül",
|
|
10
10
|
author_email="urazdev@gmail.com",
|
|
11
11
|
description="A scalable Python library for fetching, processing, and exporting structured football match data.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|