Skip to content

Commit

Permalink
pushing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tlentz committed Nov 13, 2016
1 parent b4406a8 commit a0e6b41
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 36 deletions.
116 changes: 116 additions & 0 deletions dataStuff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*$query = "SELECT * FROM Team";
$teams = r2a($mysqli->query($query));
$new_teams = array();
foreach($teams as $t) {
$new_teams[$t['abbr']] = $t['teamID'];
}
$query = "SELECT * FROM Position";
$positions = r2a($mysqli->query($query));
$pos = array();
foreach($positions as $p) {
$pos[$p['name']] = $p['positionID'];
}
$file = fopen("scrape_data/players.txt", "r") or die("Unable to open file!");
while(!feof($file)) {
$line = fgets($file);
if($line != "") {
$parts = explode(" -- ",$line);
$query = "INSERT INTO Player (name,teamID,positionID) VALUES ('".str_replace("'","",$parts[1])."','".$new_teams[trim($parts[2])]."','".$pos[$parts[0]]."')";
$mysqli->query($query);
}
}
fclose($file);*/
/*
$query = "SELECT * FROM Week
WHERE season = 1";
$temp_weeks = r2a($mysqli->query($query));
$weeks = array();
foreach($temp_weeks as $t) {
$weeks[$t['weekNum']] = $t['weekID'];
}
$query = "SELECT p.*, pos.name as 'pos', t.abbr
FROM Player p
JOIN Position pos
ON p.positionID = pos.positionID
JOIN Team t
ON t.teamID = p.teamID";
$temp_players = r2a($mysqli->query($query));
$players = array();
foreach($temp_players as $t) {
$index = $t['pos'].$t['name'].$t['abbr'];
$index = str_replace("'","",$index);
$players[$index] = $t['playerID'];
}
$file = fopen("scrape_data/2015/RBWRTE.csv", "r") or die("Unable to open file!");
while(!feof($file)) {
$line = fgets($file);
if($line != "") {
$parts = explode(",",$line);
$week = $parts[0];
$pos = $parts[1];
$name = $parts[2];
$abbr = $parts[3];
$index = $pos.$name.$abbr;
$index = str_replace("'","",$index);
$playerID = $players[$index];

// DEFENSE //
/*
$sacks = $parts[5];
$fr = $parts[6];
$int = $parts[7];
$td = $parts[8];
$sfty = $parts[9];
$ryda = $parts[10];
$pyda = $parts[11];
$tyda = $parts[12];
$query = "INSERT INTO PlayerStat (playerID,weekID,defSack,defFR,defInt,defTds,defSafety,defRYA,defPYA,defTYA)
VALUES (".$playerID.",".$weeks[$week].",".$sacks.",".$fr.",".$int.",".$td.",".$sfty.",".$ryda.",".$pyda.",".$tyda.")";
$mysqli->query($query);*/

// PK //
/*
$fgAtt = $parts[5];
$fgMiss = $parts[6];
$xpAtt = $parts[7];
$xpMiss = $parts[8];
$query = "INSERT INTO PlayerStat (playerID,weekID,fgAtt,fgMiss,xpAtt,xpMiss)
VALUES (".$playerID.",".$weeks[$week].",".$fgAtt.",".$fgMiss.",".$xpAtt.",".$xpMiss.")";
$mysqli->query($query);*/

// QB //
/*
$rushAtt = $parts[6];
$rushYds = $parts[7];
$rushTds = $parts[8];
$passAtt = $parts[9];
$passComp = $parts[10];
$passYds = $parts[11];
$passTds = $parts[12];
$fumbles = $parts[13];
$interceptions = $parts[14];
$query = "INSERT INTO PlayerStat (playerID,weekID,rushAtt,rushYds,rushTds,passAtt,passComp,passYds,passTds,fumbles,interceptions)
VALUES (".$playerID.",".$weeks[$week].",".$rushAtt.",".$rushYds.",".$rushTds.",".$passAtt.",".$passComp.",".$passYds.",".$passTds.",".$fumbles.",".$interceptions.")";
$mysqli->query($query);*/

// RBWRTE //
/*
$rushAtt = $parts[6];
$rushYds = $parts[7];
$rushTds = $parts[8];
$targets = $parts[9];
$receptions = $parts[10];
$recYds = $parts[11];
$recTds = $parts[12];
$fumbles = $parts[13];
$interceptions = $parts[14];
$query = "INSERT INTO PlayerStat (playerID,weekID,rushAtt,rushYds,rushTds,targets,receptions,recYds,recTds,fumbles,interceptions)
VALUES (".$playerID.",".$weeks[$week].",".$rushAtt.",".$rushYds.",".$rushTds.",".$targets.",".$receptions.",".$recYds.",".$recTds.",".$fumbles.",".$interceptions.")";
$mysqli->query($query);*/


//$query = "INSERT INTO Player (name,teamID,positionID) VALUES ('".$parts[1]."','".$new_teams[trim($parts[2])]."','".$pos[$parts[0]]."')";
//$mysqli->query($query);
}
}
fclose($file);
22 changes: 0 additions & 22 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,6 @@
</div>

<?php
$query = "SELECT * FROM Team";
$teams = r2a($mysqli->query($query));
$new_teams = array();
foreach($teams as $t) {
$new_teams[$t['teamAbbrev']] = $t['teamID'];
}
$query = "SELECT * FROM Position";
$positions = r2a($mysqli->query($query));
$pos = array();
foreach($positions as $p) {
$pos[$p['name']] = $p['positionID'];
}
$file = fopen("scrape_data/players.txt", "r") or die("Unable to open file!");
echo "<pre>"; print_r($new_teams); echo "</pre>";
echo $new_teams['ARI'];
while(!feof($file) && fgets($file) != "") {
$line = fgets($file);
$parts = explode(" -- ",$line);
//$query = "INSERT INTO Player (name,teamID,positionID) VALUES ('".$parts[1]."','".$new_teams[trim($parts[2])]."','".$pos[$parts[0]]."')";
//$mysqli->query($query);
}
fclose($file);
include('footer.php');
?>

Expand Down
28 changes: 14 additions & 14 deletions scrape_data/2015/RBWRTE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@
1,WR,Cecil Shorts,HOU,8,6,0,0,0,8,4,57,0,0,0,
1,WR,Markus Wheaton,PIT,7,6,0,0,0,7,3,55,0,0,0,
1,WR,Chris Owusu,NYJ,6,6,0,0,0,6,4,55,0,0,0,
1,WR,Ted Ginn, Jr.,CAR,7,5,0,0,0,7,2,54,0,0,0,
1,WR,Ted Ginn Jr.,CAR,7,5,0,0,0,7,2,54,0,0,0,
1,WR,Brandin Cooks,NO,9,5,1,4,0,8,4,49,0,0,0,
1,WR,Jeremy Maclin,KC,9,5,0,0,0,9,5,52,0,0,0,
1,WR,Vincent Jackson,TB,11,5,0,0,0,11,4,51,0,0,0,
Expand Down Expand Up @@ -1658,7 +1658,7 @@
2,WR,Stevie Johnson,SD,6,10,0,0,0,6,5,45,1,0,0,
2,WR,Kenny Britt,LA,4,10,0,0,0,4,2,44,1,0,0,
2,WR,Willie Snead IV,NO,6,10,0,0,0,6,4,44,1,1,0,
2,WR,Ted Ginn, Jr.,CAR,9,10,0,0,0,9,4,41,1,0,0,
2,WR,Ted Ginn Jr.,CAR,9,10,0,0,0,9,4,41,1,0,0,
2,WR,James Jones,GB,3,9,0,0,0,3,1,29,1,0,0,
2,WR,Kamar Aiken,BAL,7,9,0,0,0,7,5,89,0,1,0,
2,WR,Aaron Dobson,NE,8,9,0,0,0,8,7,87,0,0,0,
Expand Down Expand Up @@ -1775,7 +1775,7 @@
3,WR,T.Y. Hilton,IND,7,9,0,0,0,7,4,94,0,0,0,
3,WR,Keshawn Martin,NE,3,9,0,0,0,3,3,33,1,0,0,
3,WR,Jeremy Kerley,NYJ,11,9,0,0,0,11,6,33,1,0,0,
3,WR,Ted Ginn, Jr.,CAR,6,9,0,0,0,6,4,93,0,0,0,
3,WR,Ted Ginn Jr.,CAR,6,9,0,0,0,6,4,93,0,0,0,
3,WR,Donte Moncrief,IND,7,9,0,0,0,7,4,32,1,0,0,
3,WR,Emmanuel Sanders,DEN,9,9,0,0,0,9,6,87,0,0,0,
3,WR,Julian Edelman,NE,11,8,0,0,0,11,8,85,0,0,0,
Expand Down Expand Up @@ -1878,7 +1878,7 @@
4,WR,Cecil Shorts,HOU,10,15,0,0,0,10,6,87,1,1,0,
4,WR,Mike Wallace,MIN,10,14,0,0,0,10,8,83,1,0,0,
4,WR,Kenny Stills,MIA,8,14,0,0,0,8,5,81,1,0,0,
4,WR,Ted Ginn, Jr.,CAR,3,14,0,0,0,3,2,18,2,0,0,
4,WR,Ted Ginn Jr.,CAR,3,14,0,0,0,3,2,18,2,0,0,
4,WR,Kamar Aiken,BAL,7,14,0,0,0,7,5,77,1,0,0,
4,WR,Keenan Allen,SD,7,13,0,0,0,7,4,72,1,0,0,
4,WR,Riley Cooper,PHI,3,13,0,0,0,3,2,72,1,0,0,
Expand Down Expand Up @@ -2169,7 +2169,7 @@
6,WR,Josh Huff,PHI,3,2,0,0,0,3,3,19,0,0,0,
6,WR,Dwayne Harris,NYG,4,2,0,0,0,4,2,18,0,0,0,
6,WR,Andre Caldwell,DEN,2,2,0,0,0,2,2,18,0,0,0,
6,WR,Ted Ginn, Jr.,CAR,4,2,0,0,0,4,1,18,0,0,0,
6,WR,Ted Ginn Jr.,CAR,4,2,0,0,0,4,1,18,0,0,0,
6,WR,Chris Givens,BAL,2,2,0,0,0,2,2,18,0,0,0,
6,WR,Quincy Enunwa,NYJ,3,2,0,0,0,3,2,17,0,0,0,
6,WR,Chris Conley,KC,7,2,0,0,0,7,3,16,0,0,0,
Expand Down Expand Up @@ -2224,7 +2224,7 @@
7,WR,Ryan Grant,WAS,3,11,0,0,0,3,3,54,1,0,0,
7,WR,Allen Hurns,JAC,8,11,0,0,0,8,2,53,1,0,0,
7,WR,Kendall Wright,TEN,8,11,0,0,0,8,4,46,1,0,0,
7,WR,Ted Ginn, Jr.,CAR,9,10,1,43,0,8,5,59,0,0,0,
7,WR,Ted Ginn Jr.,CAR,9,10,1,43,0,8,5,59,0,0,0,
7,WR,Eric Decker,NYJ,12,9,0,0,0,12,6,94,0,0,0,
7,WR,Donte Moncrief,IND,6,9,0,0,0,6,4,34,1,0,0,
7,WR,Keenan Allen,SD,13,9,0,0,0,13,9,89,0,0,0,
Expand Down Expand Up @@ -2343,7 +2343,7 @@
8,WR,Jeremy Kerley,NYJ,5,6,0,0,0,5,4,63,0,0,0,
8,WR,Kamar Aiken,BAL,6,6,0,0,0,6,6,62,0,0,0,
8,WR,Rishard Matthews,MIA,12,6,0,0,0,12,7,62,0,0,0,
8,WR,Ted Ginn, Jr.,CAR,10,6,0,0,0,10,2,60,0,0,0,
8,WR,Ted Ginn Jr.,CAR,10,6,0,0,0,10,2,60,0,0,0,
8,WR,Golden Tate,DET,7,6,0,0,0,7,6,59,0,0,0,
8,WR,Kenny Stills,MIA,7,6,0,0,0,7,3,58,0,0,0,
8,WR,Chris Givens,BAL,4,6,0,0,0,4,3,57,0,0,0,
Expand Down Expand Up @@ -2483,7 +2483,7 @@
9,WR,Bennie Fowler,DEN,4,2,0,0,0,4,2,22,0,0,0,
9,WR,Travis Benjamin,CLE,6,2,0,0,0,6,3,22,0,0,0,
9,WR,Jeremy Kerley,NYJ,3,2,0,0,0,3,2,22,0,0,0,
9,WR,Ted Ginn, Jr.,CAR,4,2,0,0,0,4,1,20,0,0,0,
9,WR,Ted Ginn Jr.,CAR,4,2,0,0,0,4,1,20,0,0,0,
9,WR,Roddy White,ATL,2,2,0,0,0,2,1,20,0,0,0,
9,WR,Justin Hardy,ATL,4,2,0,0,0,4,4,17,0,0,0,
9,WR,DeSean Jackson,WAS,6,2,0,0,0,6,3,15,0,0,0,
Expand Down Expand Up @@ -2555,7 +2555,7 @@
10,WR,Randall Cobb,GB,11,5,1,-3,0,10,5,53,0,0,0,
10,WR,Justin Hunter,TEN,4,5,0,0,0,4,4,47,0,0,0,
10,WR,Dez Bryant,DAL,12,4,0,0,0,12,5,45,0,0,0,
10,WR,Ted Ginn, Jr.,CAR,8,4,0,0,0,8,4,45,0,0,0,
10,WR,Ted Ginn Jr.,CAR,8,4,0,0,0,8,4,45,0,0,0,
10,WR,DeSean Jackson,WAS,5,4,0,0,0,5,2,44,0,0,0,
10,WR,Devin Funchess,CAR,2,4,0,0,0,2,2,41,0,0,0,
10,WR,Paul Richardson,SEA,1,4,0,0,0,1,1,40,0,0,0,
Expand Down Expand Up @@ -2639,7 +2639,7 @@
11,WR,John Brown,ARI,5,11,2,9,0,3,3,43,1,0,0,
11,WR,Kenny Stills,MIA,2,11,0,0,0,2,2,52,1,0,0,
11,WR,Kamar Aiken,BAL,8,11,0,0,0,8,5,50,1,0,0,
11,WR,Ted Ginn, Jr.,CAR,10,11,2,12,0,8,5,37,1,0,0,
11,WR,Ted Ginn Jr.,CAR,10,11,2,12,0,8,5,37,1,0,0,
11,WR,Brandon Marshall,NYJ,10,11,0,0,0,10,5,47,1,0,0,
11,WR,Dez Bryant,DAL,9,10,0,0,0,9,4,45,1,0,0,
11,WR,Marquess Wilson,CHI,7,10,0,0,0,7,4,102,0,0,0,
Expand Down Expand Up @@ -2851,7 +2851,7 @@
13,WR,Jeremy Maclin,KC,10,22,0,0,0,10,9,95,2,1,0,
13,WR,Doug Baldwin,SEA,7,21,0,0,0,7,5,94,2,0,0,
13,WR,Odell Beckham Jr,NYG,11,21,0,0,0,11,6,149,1,0,0,
13,WR,Ted Ginn, Jr.,CAR,10,20,0,0,0,10,5,80,2,0,0,
13,WR,Ted Ginn Jr.,CAR,10,20,0,0,0,10,5,80,2,0,0,
13,WR,Brandon Marshall,NYJ,13,19,0,0,0,13,12,131,1,0,0,
13,WR,A.J. Green,CIN,6,19,0,0,0,6,5,128,1,0,0,
13,WR,Dorial Green-Beckham,TEN,6,18,0,0,0,6,5,119,1,0,0,
Expand Down Expand Up @@ -2967,7 +2967,7 @@
13,WR,Travis Benjamin,CLE,2,0,0,0,0,2,0,0,0,0,0,
14,WR,Odell Beckham Jr,NYG,9,29,0,0,0,9,7,166,2,0,0,
14,WR,Doug Baldwin,SEA,9,26,0,0,0,9,6,82,3,0,0,
14,WR,Ted Ginn, Jr.,CAR,4,24,1,5,0,3,2,120,2,0,0,
14,WR,Ted Ginn Jr.,CAR,4,24,1,5,0,3,2,120,2,0,0,
14,WR,Tyler Lockett,SEA,7,22,0,0,0,7,6,104,2,0,0,
14,WR,Golden Tate,DET,11,20,1,15,0,10,9,60,2,0,0,
14,WR,A.J. Green,CIN,9,19,0,0,0,9,6,132,1,0,0,
Expand Down Expand Up @@ -3094,7 +3094,7 @@
15,WR,Sammy Watkins,BUF,10,23,0,0,0,10,5,111,2,0,0,
15,WR,Jordan Matthews,PHI,11,22,0,0,0,11,8,159,1,0,0,
15,WR,DeSean Jackson,WAS,8,21,0,0,0,8,6,153,1,0,0,
15,WR,Ted Ginn, Jr.,CAR,14,20,0,0,0,14,6,85,2,0,0,
15,WR,Ted Ginn Jr.,CAR,14,20,0,0,0,14,6,85,2,0,0,
15,WR,Tavon Austin,LA,7,19,4,32,1,3,3,41,1,0,0,
15,WR,Kamar Aiken,BAL,12,19,0,0,0,12,8,128,1,0,0,
15,WR,Brandin Cooks,NO,13,18,0,0,0,13,10,124,1,0,0,
Expand Down Expand Up @@ -3312,7 +3312,7 @@
16,WR,Martavis Bryant,PIT,4,1,1,4,0,3,1,6,0,0,0,
16,WR,Adam Humphries,TB,2,1,0,0,0,2,1,10,0,0,0,
16,WR,Amari Cooper,OAK,3,1,0,0,0,3,2,10,0,0,0,
16,WR,Ted Ginn, Jr.,CAR,3,1,0,0,0,3,1,9,0,0,0,
16,WR,Ted Ginn Jr.,CAR,3,1,0,0,0,3,1,9,0,0,0,
16,WR,Ben Edwards,NYG,2,1,0,0,0,2,1,9,0,0,0,
16,WR,Josh Huff,PHI,2,1,0,0,0,2,1,8,0,0,0,
16,WR,Jonathan Krause,PHI,2,1,0,0,0,2,1,7,0,0,0,
Expand Down

0 comments on commit a0e6b41

Please sign in to comment.