Skip to content

Commit

Permalink
python csv reader
Browse files Browse the repository at this point in the history
  • Loading branch information
WAB2014 authored and WAB2014 committed Jul 31, 2014
1 parent 7b03b8e commit 12a72a3
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 4 deletions.
40 changes: 36 additions & 4 deletions FOOTBALLreader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
import csv

teamname = 'Tottenham'
goals = 0
wins = 0
losses = 0
draws = 0
with open('footieINFO.csv', 'r') as file:
reader = csv.reader(file)
i = 0
i=0
for row in reader:
print(', '.join(row[1:7]))
if i == 5:
break
if row[2] == teamname: #games played by team at home
goals = goals + int(row[4]) #goals
print(', '.join(row[1:7]))
if int(row[4]) > int(row[5]): #home goals greater than away goals
wins = wins + 1 #wins
elif int (row[4]) < int(row[5]):#away goals greater than away goals
losses = losses +1 #losses
else:
draws = draws +1 #draws

if row[3] == teamname: #games played by team away
goals = goals + int(row[5]) #goals
print(', '.join(row[1:7]))
if int(row[5]) > int(row[4]): #home goals greater than away goals
wins = wins + 1 #wins
elif int (row[5]) < int(row[4]):#away goals greater than away goals
losses = losses +1 #losses
else:
draws = draws +1 #draws
#if i == 5:
# break
i += 1

print('Goals by '+teamname+': '+str(goals))
print('Wins: '+str(wins))
print('Losses: '+str(losses))
print('Draws: '+str(draws))
print(teamname+','+str(goals)+','+str(wins)+','+str(losses)+','+str(draws))
statsfile = open('/Users/William03/GitHub/penalty-game-project/statsfile.csv','a')
statsfile.write('\n'+teamname+','+str(goals)+','+str(wins)+','+str(losses)+','+str(draws))
statsfile.close()
Binary file added footieINFO.numbers/Index.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions footieINFO.numbers/Metadata/BuildVersionHistory.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>csv</string>
<string>M3.2-1861-1</string>
</array>
</plist>
1 change: 1 addition & 0 deletions footieINFO.numbers/Metadata/DocumentIdentifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
539A06AC-75F6-43DE-98F2-0F7A4E40657D
Binary file added footieINFO.numbers/Metadata/Properties.plist
Binary file not shown.
Binary file added footieINFO.numbers/preview-micro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added footieINFO.numbers/preview-web.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added footieINFO.numbers/preview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified proper yrs footie project.sb2
Binary file not shown.
24 changes: 24 additions & 0 deletions statsfile.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Arsenal,68,24,7,7
Chelsea,71,25,6,7
Manchester United,0,0,0,0
Man United,64,19,12,7
Man City,102,27,6,5
Aston Villa,39,10,20,8
Liverpool,101,26,6,6
Stoke,45,13,14,11
Norwich,28,8,21,9
Everton,61,21,8,9
Sunderland,41,10,20,8
Fulham,40,9,24,5
Swansea,54,11,18,9
West Brom,43,7,16,15
Southamton,0,0,0,0
West Ham,40,11,20,7
Southampton,54,15,12,11
Cardiff,32,7,22,9
Cardiff,32,7,22,9
Hull,38,10,21,7
Hull,38,10,21,7
Crystal Palace,33,13,19,6
Tottenham,55,21,11,6
Binary file added statsfile.numbers/Index.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions statsfile.numbers/Metadata/BuildVersionHistory.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>csv</string>
<string>M3.2-1861-1</string>
</array>
</plist>
1 change: 1 addition & 0 deletions statsfile.numbers/Metadata/DocumentIdentifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0909E6DC-DBC4-4EFD-BEDE-CB88FC7CFC3F
Binary file added statsfile.numbers/Metadata/Properties.plist
Binary file not shown.
Binary file added statsfile.numbers/preview-micro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added statsfile.numbers/preview-web.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added statsfile.numbers/preview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions statsfile.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210
{\fonttbl}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
}

0 comments on commit 12a72a3

Please sign in to comment.