{"id":19123664,"url":"https://github.com/sportdb/sports","last_synced_at":"2025-10-08T04:51:44.659Z","repository":{"id":16085674,"uuid":"18830356","full_name":"sportdb/sports","owner":"sportdb","description":"require 'sports' - sports (football) quick starter samples","archived":false,"fork":false,"pushed_at":"2025-01-03T18:31:21.000Z","size":150,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T11:09:00.654Z","etag":null,"topics":["csv","fbtxt","football","opendata"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"CISY242-F16/Lab6B-Brian-s-Brain-to-Game-of-Life","license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sportdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-16T07:10:53.000Z","updated_at":"2025-01-03T18:31:24.000Z","dependencies_parsed_at":"2024-10-18T13:46:22.194Z","dependency_job_id":"a72a3a9d-09bf-4cb8-8d8a-75145d6fb972","html_url":"https://github.com/sportdb/sports","commit_stats":null,"previous_names":["sportdb/fifa","sportdb/sports"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sportdb%2Fsports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sportdb%2Fsports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sportdb%2Fsports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sportdb%2Fsports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sportdb","download_url":"https://codeload.github.com/sportdb/sports/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252556002,"owners_count":21767275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","fbtxt","football","opendata"],"created_at":"2024-11-09T05:26:42.555Z","updated_at":"2025-10-08T04:51:39.643Z","avatar_url":"https://github.com/sportdb.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# require 'sports' - sports (football) quick starter samples \u0026 more\r\n\r\n\r\n## Usage\r\n\r\n\r\n### Working with CSV Datafiles\r\n\r\nLet's build the standings table for the English Premier League (EPL) for the 2019/20 season from all matches\r\nin the comma-separated values (.csv) format.\r\nExample:\r\n\r\n```\r\n                                        - Home -          - Away -            - Total -\r\n                                 Pld   W  D  L   F:A     W  D  L   F:A      F:A   +/-  Pts\r\n 1. Liverpool FC                  38  18  1  0  52:16   14  2  3  33:17    85:33  +52   99\r\n 2. Manchester City FC            38  15  2  2  57:13   11  1  7  45:22   102:35  +67   81\r\n 3. Manchester United FC          38  10  7  2  40:17    8  5  6  26:19    66:36  +30   66\r\n 4. Chelsea FC                    38  11  3  5  30:16    9  3  7  39:38    69:54  +15   66\r\n 5. Leicester City FC             38  11  4  4  35:17    7  4  8  32:24    67:41  +26   62\r\n 6. Tottenham Hotspur FC          38  12  3  4  36:17    4  8  7  25:30    61:47  +14   59\r\n 7. Wolverhampton Wanderers FC    38   8  7  4  27:19    7  7  5  24:21    51:40  +11   59\r\n 8. Arsenal FC                    38  10  6  3  36:24    4  8  7  20:24    56:48   +8   56\r\n 9. Sheffield United FC           38  10  3  6  24:15    4  9  6  15:24    39:39        54\r\n10. Burnley FC                    38   8  4  7  24:23    7  5  7  19:27    43:50   -7   54\r\n11. Southampton FC                38   6  3 10  21:35    9  4  6  30:25    51:60   -9   52\r\n12. Everton FC                    38   8  7  4  24:21    5  3 11  20:35    44:56  -12   49\r\n13. Newcastle United FC           38   6  8  5  20:21    5  3 11  18:37    38:58  -20   44\r\n14. Crystal Palace FC             38   6  5  8  15:20    5  5  9  16:30    31:50  -19   43\r\n15. Brighton \u0026 Hove Albion FC     38   5  7  7  20:27    4  7  8  19:27    39:54  -15   41\r\n16. West Ham United FC            38   6  4  9  30:33    4  5 10  19:29    49:62  -13   39\r\n17. Aston Villa FC                38   7  3  9  22:30    2  5 12  19:37    41:67  -26   35\r\n18. AFC Bournemouth               38   5  6  8  22:30    4  1 14  18:35    40:65  -25   34\r\n19. Watford FC                    38   6  6  7  22:27    2  4 13  14:37    36:64  -28   34\r\n20. Norwich City FC               38   4  3 12  19:37    1  3 15   7:38    26:75  -49   21\r\n```\r\n\r\n\r\nStep 0: Download the free public domain [`/england`](https://github.com/footballcsv/england) dataset package / archive from the [football.csv org](https://footballcsv.github.io).\r\n\r\nWhat's the comma-separated values (.csv) format?\r\nIt's the world's most popular tabular data interchange format in text.\r\nValues are separated - surprise, surprise - by commas (that is, `,`).\r\nOne line is one record, that is, one match :-).\r\nExample:\r\n\r\n```\r\nTeam 1,               FT,  HT,  Team 2\r\nLiverpool FC,         4-1, 4-0, Norwich City FC\r\nWest Ham United FC,   0-5, 0-1, Manchester City FC\r\nAFC Bournemouth,      1-1, 0-0, Sheffield United FC\r\nBurnley FC,           3-0, 0-0, Southampton FC\r\nCrystal Palace FC,    0-0, 0-0, Everton FC\r\nWatford FC,           0-3, 0-1, Brighton \u0026 Hove Albion FC\r\nTottenham Hotspur FC, 3-1, 0-1, Aston Villa FC\r\nLeicester City FC,    0-0, 0-0, Wolverhampton Wanderers FC\r\nNewcastle United FC,  0-1, 0-0, Arsenal FC\r\nManchester United FC, 4-0, 1-0, Chelsea FC\r\n...\r\n```\r\n\r\nLet's use the [`eng.1.csv`](https://github.com/footballcsv/england/blob/master/2010s/2019-20/eng.1.csv), that is, the English Premier League datafile in the `/2010s/2019-20` folder.\r\nRead in all matches with the `Match.read_csv` method from the sports library / gem:\r\n\r\n\r\n``` ruby\r\nrequire 'sports'\r\n\r\nmatches = Match.read_csv( 'england/2010s/2019-20/eng.1.csv' )\r\npp matches.size  #=\u003e 380\r\npp matches\r\n```\r\n\r\nwill pretty print (pp):\r\n\r\n```\r\n[#\u003cSports::Match\r\n  @date    = \"2019-08-09\",\r\n  @score1  = 4,\r\n  @score1i = 4,\r\n  @score2  = 1,\r\n  @score2i = 0,\r\n  @team1   = \"Liverpool FC\",\r\n  @team2   = \"Norwich City FC\"\u003e,\r\n #\u003cSports::Match\r\n  @date    = \"2019-08-10\",\r\n  @score1  = 0,\r\n  @score1i = 0,\r\n  @score2  = 5,\r\n  @score2i = 1,\r\n  @team1   = \"West Ham United FC\",\r\n  @team2   = \"Manchester City FC\"\u003e,\r\n  ...]\r\n```\r\n\r\nNow tally up all matches for the standings table with the standings helper class:\r\n\r\n``` ruby\r\nstandings = Standings.new( matches )\r\npp standings\r\n```\r\n\r\nwill pretty print (pp):\r\n\r\n```\r\n#\u003cSports::Standings @lines=[\r\n   #\u003cSports::StandingsLine\r\n     @away_drawn         = 0,\r\n     @away_goals_against = 1,\r\n     @away_goals_for     = 5,\r\n     @away_lost          = 0,\r\n     @away_played        = 2,\r\n     @away_pts           = 6,\r\n     @away_won           = 2,\r\n     @drawn              = 0,\r\n     @goals_against      = 3,\r\n     @goals_for          = 12,\r\n     @home_drawn         = 0,\r\n     @home_goals_against = 2,\r\n     @home_goals_for     = 7,\r\n     @home_lost          = 0,\r\n     @home_played        = 2,\r\n     @home_pts           = 6,\r\n     @home_won           = 2,\r\n     @lost               = 0,\r\n     @played             = 4,\r\n     @pts                = 12,\r\n     @rank               = 1,\r\n     @team               = \"Liverpool FC\",\r\n     @won                = 4\u003e,\r\n   #\u003cSports::StandingsLine\r\n     @away_drawn         = 0,\r\n     @away_goals_against = 6,\r\n     @away_goals_for     = 1,\r\n     @away_lost          = 2,\r\n     @away_played        = 2,\r\n     @away_pts           = 0,\r\n     @away_won           = 0,\r\n     @drawn              = 0,\r\n     @goals_against      = 10,\r\n     @goals_for          = 6,\r\n     @home_drawn         = 0,\r\n     @home_goals_against = 4,\r\n     @home_goals_for     = 5,\r\n     @home_lost          = 1,\r\n     @home_played        = 2,\r\n     @home_pts           = 3,\r\n     @home_won           = 1,\r\n     @lost               = 3,\r\n     @played             = 4,\r\n     @pts                = 3,\r\n     @rank               = 19,\r\n     @team               = \"Norwich City FC\",\r\n     @won                = 1\u003e,\r\n   ... ]\u003e\r\n```\r\n\r\nNow let's format the standings for humans :-) in the classic more compact table format.\r\nLet's start with\r\nshowing only totals - no home/away break outs yet -\r\nin the first simple version:\r\n\r\n``` ruby\r\nstandings.each do |l|\r\n  print '%2d. '     % l.rank\r\n  print '%-28s  '   % l.team\r\n  print '%2d '      % l.played\r\n  print '%3d '      % l.won\r\n  print '%3d '      % l.drawn\r\n  print '%3d '      % l.lost\r\n  print '%3d:%-3d ' % [l.goals_for,l.goals_against]\r\n  print '%3d'       % l.pts\r\n  print \"\\n\"\r\nend\r\n```\r\n\r\nresulting in:\r\n\r\n```\r\n 1. Liverpool FC                  38  32   3   3  85:33   99\r\n 2. Manchester City FC            38  26   3   9 102:35   81\r\n 3. Manchester United FC          38  18  12   8  66:36   66\r\n 4. Chelsea FC                    38  20   6  12  69:54   66\r\n 5. Leicester City FC             38  18   8  12  67:41   62\r\n 6. Tottenham Hotspur FC          38  16  11  11  61:47   59\r\n 7. Wolverhampton Wanderers FC    38  15  14   9  51:40   59\r\n 8. Arsenal FC                    38  14  14  10  56:48   56\r\n 9. Sheffield United FC           38  14  12  12  39:39   54\r\n10. Burnley FC                    38  15   9  14  43:50   54\r\n11. Southampton FC                38  15   7  16  51:60   52\r\n12. Everton FC                    38  13  10  15  44:56   49\r\n13. Newcastle United FC           38  11  11  16  38:58   44\r\n14. Crystal Palace FC             38  11  10  17  31:50   43\r\n15. Brighton \u0026 Hove Albion FC     38   9  14  15  39:54   41\r\n16. West Ham United FC            38  10   9  19  49:62   39\r\n17. Aston Villa FC                38   9   8  21  41:67   35\r\n18. AFC Bournemouth               38   9   7  22  40:65   34\r\n19. Watford FC                    38   8  10  20  36:64   34\r\n20. Norwich City FC               38   5   6  27  26:75   21\r\n```\r\n\r\nTo wrap up let's break out the standings for home and away matches for a deluxe version:\r\n\r\n``` ruby\r\nprint \"                                        - Home -          - Away -            - Total -\\n\"\r\nprint \"                                 Pld   W  D  L   F:A     W  D  L   F:A      F:A   +/-  Pts\\n\"\r\n\r\nstandings.each do |l|\r\n  print '%2d. '      % l.rank\r\n  print '%-28s  '    % l.team\r\n  print '%2d  '      % l.played\r\n\r\n  print '%2d '       % l.home_won\r\n  print '%2d '       % l.home_drawn\r\n  print '%2d '       % l.home_lost\r\n  print '%3d:%-3d  ' % [l.home_goals_for,l.home_goals_against]\r\n\r\n  print '%2d '       % l.away_won\r\n  print '%2d '       % l.away_drawn\r\n  print '%2d '       % l.away_lost\r\n  print '%3d:%-3d  ' % [l.away_goals_for,l.away_goals_against]\r\n\r\n  print '%3d:%-3d '  % [l.goals_for,l.goals_against]\r\n\r\n  goals_diff = l.goals_for-l.goals_against\r\n  if goals_diff \u003e 0\r\n    print '%3s  '  %  \"+#{goals_diff}\"\r\n  elsif goals_diff \u003c 0\r\n    print '%3s  '  %  \"#{goals_diff}\"\r\n  else ## assume 0\r\n    print '     '\r\n  end\r\n\r\n  print '%3d'  % l.pts\r\n  print \"\\n\"\r\nend\r\n```\r\n\r\nresulting in:\r\n\r\n```\r\n                                        - Home -          - Away -            - Total -\r\n                                 Pld   W  D  L   F:A     W  D  L   F:A      F:A   +/-  Pts\r\n 1. Liverpool FC                  38  18  1  0  52:16   14  2  3  33:17    85:33  +52   99\r\n 2. Manchester City FC            38  15  2  2  57:13   11  1  7  45:22   102:35  +67   81\r\n 3. Manchester United FC          38  10  7  2  40:17    8  5  6  26:19    66:36  +30   66\r\n 4. Chelsea FC                    38  11  3  5  30:16    9  3  7  39:38    69:54  +15   66\r\n 5. Leicester City FC             38  11  4  4  35:17    7  4  8  32:24    67:41  +26   62\r\n 6. Tottenham Hotspur FC          38  12  3  4  36:17    4  8  7  25:30    61:47  +14   59\r\n 7. Wolverhampton Wanderers FC    38   8  7  4  27:19    7  7  5  24:21    51:40  +11   59\r\n 8. Arsenal FC                    38  10  6  3  36:24    4  8  7  20:24    56:48   +8   56\r\n 9. Sheffield United FC           38  10  3  6  24:15    4  9  6  15:24    39:39        54\r\n10. Burnley FC                    38   8  4  7  24:23    7  5  7  19:27    43:50   -7   54\r\n11. Southampton FC                38   6  3 10  21:35    9  4  6  30:25    51:60   -9   52\r\n12. Everton FC                    38   8  7  4  24:21    5  3 11  20:35    44:56  -12   49\r\n13. Newcastle United FC           38   6  8  5  20:21    5  3 11  18:37    38:58  -20   44\r\n14. Crystal Palace FC             38   6  5  8  15:20    5  5  9  16:30    31:50  -19   43\r\n15. Brighton \u0026 Hove Albion FC     38   5  7  7  20:27    4  7  8  19:27    39:54  -15   41\r\n16. West Ham United FC            38   6  4  9  30:33    4  5 10  19:29    49:62  -13   39\r\n17. Aston Villa FC                38   7  3  9  22:30    2  5 12  19:37    41:67  -26   35\r\n18. AFC Bournemouth               38   5  6  8  22:30    4  1 14  18:35    40:65  -25   34\r\n19. Watford FC                    38   6  6  7  22:27    2  4 13  14:37    36:64  -28   34\r\n20. Norwich City FC               38   4  3 12  19:37    1  3 15   7:38    26:75  -49   21\r\n```\r\n\r\n\r\nThat's it.\r\nBonus: Why not build a standings table for the Bundesliga, La Liga, Ligue 1, Seria A, or your very own league? Yes, you can.\r\n\r\n\r\n\r\n## Installation\r\n\r\nUse\r\n\r\n    gem install sports\r\n\r\nor add the gem to your Gemfile\r\n\r\n    gem 'sports'\r\n\r\n\r\n\r\n## Questions? Comments?\r\n\r\nYes, you can. More than welcome.\r\nSee [Help \u0026 Support »](https://github.com/openfootball/help)\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsportdb%2Fsports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsportdb%2Fsports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsportdb%2Fsports/lists"}