Skip to content

Instantly share code, notes, and snippets.

@efosong
Last active January 22, 2016 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efosong/0323456d9fe9357562e3 to your computer and use it in GitHub Desktop.
Save efosong/0323456d9fe9357562e3 to your computer and use it in GitHub Desktop.
Reformats data found on 'the-chase.wikia.com' into a CSV file
|1
|Anne Hegerty
|2 contestants banked £6,000.
|Target of 14 caught with 0:47 remaining.
|-
|2
|Mark Labbett
|4 contestants banked £60,000.
|Target of 19/Chaser scored 18<br />Each player wins '''£15,000'''.
|-
|3
|Shaun Wallace
|2 contestants banked £50,000.
|Target of 17 caught with 0:02 remaining.
|-
|4
|Mark Labbett
|3 contestants banked £35,000.
|Target of 19 caught with 0:06 remaining.
|-
|5
|Paul Sinha
|2 contestants banked £9,000.
|Target of 11 caught with 1:01 remaining.
|-
|6
|Paul Sinha
|2 contestants banked £5,200
|Target of 15 caught with 0:48 remaining.
|-
|7
|Anne Hegarty
|3 contestants banked £6,000
|Target of 16 caught with 0:39 remaining.
|-
|8
|Shaun Wallace
|2 contestants banked £14,000
|Target of 16 caught with 0:35 remaining.
|-
|9
|Anne Hegarty
|2 contestants banked £11,000
|Target of 18/Chaser scored 15<br />Each player wins '''£5,500'''.
|-
|10
|Mark Labbett
|3 contestants banked £12,000
|Target of 13 caught with 0:27 remaining.
|-
|11
|Shaun Wallace
|3 contestants banked £14,000
|Target of 15 caught with 0:22 remaining.
|-
|12
|Mark Labbett
|1 contestants banked £5,000
|Target of 17 caught with 0:38 remaining.
|-
|13
|Shaun Wallace
|4 contestants banked £18,000
|Target of 20/Chaser scored 17<br />Each player wins '''£4,500'''.
|-
|14
|Anne Hegarty
|2 contestants banked £3,000
|Target of 17 caught with 0:41 remaining.
|-
|15
|Paul Sinha
|2 contestants banked £36,000
|Target of 18 caught with 0:03 remaining.
|-
|16
|Anne Hegerty
|3 contestants banked £6,000
|Target of 15 caught With 0:20 remaining
|-
|17
|Paul Sinha
|4 contestants banked £14,000
|Target of 17 Caught With 0:36 Remaining
|-
|18
|Mark Labbett
|2 contestants banked £13.000
|Target of 17 caught With 0:40 Remaining
|-
|19
|Paul Sinha
|4 contestants banked £46,000
|Target of 21/Chaser Scored 20<br/>Each Player Won '''£11,500'''.
|-
|20
|Shaun Wallace
|1 contestant banked £7,000
|Target of 10 caught With 0:17 remaining
|-
|21
|Mark Labbett
|4 contestants banked £57,000
|Target of 19 caught With 0:11 remaining
|-
|22
|Anne Hegerty
|2 contestants banked £10,000
|Target of 17 caught With 0:04 remaining
|-
|23
|Shaun Wallace
|2 contestants banked £8,000
|Target of 13 caught with 0:44 remaining
|-
|24
|Mark Labbett
|4 contestants banked £18.000
|Target of 18/Chaser Scored 14<br/>Each Player Won '''£4,500'''.
|-
|25
|Paul Sinha
|2 contestants banked £6.000
|Target of 15 caught With 0:41 remaining
|-
|26
|Anne Hegerty
|3 contestants banked £12,000
|Target of 20/Chaser Scored 18<br/>Each Player Won '''£4,000'''.
|-
|27
|Mark Labbett
|3 contestants banked £21,000
|Target of 18 caught with 0:44 remaining
|-
|28
|Shaun Wallace
|1 contestant banked £5,000
|Target of 16 caught with 0:07 remaining
|-
|29
|Paul Sinha
|3 contestants banked £39.000
|Target of 19/Chaser Scored 18<br/>Each Player Won '''£13,000'''
|-
|30
|Anne Hegerty
|3 contestants banked £21.000
|Target of 14 caught with 0:23 remaining
|-
|31
|Shaun Wallace
|2 contestants banked £7.000
|Target of 15 caught with 0:44 remaining
|-
|32
|Mark Labbett
|2 contestants banked £10.000
|Target of 18 caught with 0:01 remaining
|-
|33
|Shaun Wallace
|3 contestants banked £15,000
|Target of 24/Chaser Scored 11<br/>Each Player Won '''£5,000'''
|-
|34
|Paul Sinha
|3 contestants banked £60,000
|Target of 14 caught with 0:44 remaining
|-
|35
|Anne Hegerty
|2 contestants banked £8,000
|Target of 12 caught with 0:07 Remaining
|-
|36
|Mark Labbett
|4 contestants banked £14,000
|Target of 15 caught with 0:09 remaining
|-
|37
|Paul Sinha
|1 contestant banked £5,000
|Target of 11 caught with 0:31 remaining
|-
|38
|Shaun Wallace
|2 contestants banked £13,000
|Target of 14 caught with 0:33 remaining
|-
|39
|Paul Sinha
|4 contestants banked £18.000
|Target of 16/Chaser Scored 14<br/>Each Player Won '''£4,500'''
|-
|40
|Anne Hegerty
|2 contestants banked £42,000
|Target of 12 caught with 0:29 remaining
|-
|41
|Paul Sinha
|3 contestants banked £11,000
|Target of 14 caught with 0:46 remaining
|-
|42
|Shaun Wallace
|4 contestants banked £19,000
|Target of 18/Chaser Scored 14<br/>Each Player Won '''£4,750'''
|-
|43
|Mark Labbett
|3 contestants banked £14,000
|Target of 16 caught with 0:24 remaining
|-
|44
|Anne Hegerty
|4 contestants banked £17,000
|Target of 17 caught with 0:11 remaining
|-
|45
|Mark Labbett
|3 contestants banked £12,000
|Target of 19 caught with 0:07 remaining
|-
|46
|Mark Labbett
|1 contestant banked £500
|Target of 8 caught with 1:22 remaining
|-
|47
|Anne Hegerty
|2 contestants banked £4,000
|Target of 16 caught with 0:45 remaining
|-
|48
|Paul Sinha
|1 contestant banked £3,000
|Target of 13 caught with 0:38 remaining
|-
|49
|Shaun Wallace
|3 contestants banked £26,000
|Target of 19 caught with 0:02 remaining
|-
|50
|Anne Hegerty
|2 contestants banked £10,000
|Target of 13 caught with 0:55 remaining
|-
|51
|Paul Sinha
|2 contestants banked £42,000
|Target of 17/Chaser Scored 10<br/>Each Player Won '''£21.000'''
|-
|52
|Mark Labbett
|4 contestants banked £63.000
|Target of 15 caught with 0:30 remaining
|-
|53
|Mark Labbett
|3 contestants banked £18,000
|Target of 22 caught with 0:00 remaining
|-
|54
|Anne Hegerty
|2 contestants banked £10,000
|Target of 18/Chaser Scored 11<br/>Each Player Won '''£5,000'''
|-
|55
|Paul Sinha
|2 contestants banked £7,000
|Target of 15 caught with 0:39 remaining
|-
|56
|Shaun Wallace
|3 contestants banked £11.000
|Target of 19/Chaser Scored 15<br/> Each Player Won '''£3.666.67'''
|-
|57
|Anne Hegerty
|2 contestants banked £7.000
|Target of 14 Caught With 0:56 Remaining
|-
|58
|Anne Hegerty
|2 contestants banked £9.000
|Target of 14 Caught With 0:20 Remaining
|-
|59
|Mark Labbett
|3 contestants banked £13.999
|Target of 20/Chaser Scored 15<br/> Each Player Won '''£4.666.33'''
|-
|60
|Paul Sinha
|4 contestants banked £16:000
|Target of 18 Caught With 0:10 Remaining
|-
|61
|Mark Labbett
|3 contestants banked £13.000
|Target of 17 Caught With 0:25 Remaining
|-
|62
|Shaun Wallace
|1 contestant banked £4.000
|Target of 10 Caught With 1:09 Remaining
|-
|63
|Shaun Wallace
|3 contestants banked £15.000
|Target of 15 Caught With 0:51 Remaining
|-
|64
|Paul Sinha
|3 contestants banked £14.000
|Target of 17 Caught With 0:19 Remaining
|-
|65
|Anne Hegerty
|2 contestants banked £8.000
|Target of 10 Caught With 0:59 Remaining
|-
|66
|Shaun Wallace
|3 contestants banked £15.000
|Target of 17/Chaser Scored 12<br/> Each Player Won '''£5.000'''
|-
|67
|Mark Labbett
|4 contestants banked £16.000
|Target of 20 Caught With 0:25 Remaining
|-
|68
|Paul Sinha
|4 contestants banked £23.000
|Target of 19 Caught With 0:28 Remaining
|-
|69
|Mark Labbett
|3 contestants banked £30.000
|Target of 16 Caught With 0:27 Remaining
|-
|70
|Anne Hegerty
|2 contestants banked £8.000
|Target of 17 Caught With 0:02 Remaining
|-
|71
|Shaun Wallace
|1 contestant banked £1.000
|Target of 10 Caught With 1:11 Remaining
|-
|72
|Paul Sinha
|3 contestants banked £12.000
|Target of 14/Chaser Scored 12<br/> Each Player Won '''£4.000'''
|-
|73
|Anne Hegerty
|3 contestants banked £19.000
|Target of 20 Caught With 0:05 Remaining
|-
|74
|Paul Sinha
|4 contestants banked £12.300
|Target of 20 Caught With 0:06 Remaining
|-
|75
|Mark Labbett
|4 contestants banked £12.000
|Target of 15 Caught With 0:08 Remaining
|-
|76
|Anne Hegerty
|4 contestants banked £20.000
|Target of 23/Chaser Scored 17<br/> Each Player Won '''£5.000'''
|-
|77
|Shaun Wallace
|2 contestants banked £60.000
|Target of 12 Caught With 0:00 Remaining
|-
|78
|Mark Labbett
|2 contestants banked £10.000
|Target of 13 Caught With 0:31 Remaining
|-
|79
|Paul Sinha
|3 contestants banked £6.000
|Target of 17 Caught With 0:24 Remaining
|-
|80
|Mark Labbett
|4 contestants banked £36.000
|Target of 21/Chaser Scored 13<br/> Each Player Won '''£9.000'''
|-
|81
|Anne Hegerty
|2 contestants banked £8.000
|Target of 16 Caught With 0:13 Remaining
|-
|82
|Shaun Wallace
|1 contestant banked £7.000
|Target of 15 Caught With 0:28 Remaining
|-
|83
|Anne Hegerty
|2 contestants banked £3.000
|Target of 15 Caught With 0:48 Remaining
|-
|84
|Shaun Wallace
|3 contestants banked £14.000
|Target of 17/Chaser Scored 16<br/> Each Player Won '''£4.666.67'''
|-
|85
|Mark Labbett
|1 contestant banked £75.000
|Target of 12 Caught With 0:55 Remaining
|-
|86
|Shaun Wallace
|2 contestants banked £13.000
|Target of 12 Caught With 0:29 Remaining
|-
|87
|Paul Sinha
|1 contestant banked £75.000
|Target of 14 Caught With 0:43 Remaining
|-
|88
|Shaun Wallace
|2 contestants banked £6.000
|Target of 14 Caught With 1:00 Remaining
|-
|89
|Paul Sinha
|1 contestant banked £6.000
|Target of 15 Caught With 0:44 Remaining
|-
|90
|Anne Hegerty
|1 contestant banked £1.000
|Target of 10 Caught With 0:42 Remaining
|-
|91
|Paul Sinha
|4 contestants banked £18.000
|Target of 22/Chaser Scored 16<br/> Each Player Won '''£4.500'''
|-
|92
|Mark Labbett
|2 contestants banked £9.000
|Target of 14 Caught With 0:00 Remaining
|-
|93
|Anne Hegerty
|2 contestants banked £9.000
|Target of 13 Caught With 0:56 Remaining
|-
|94
|Paul Sinha
|2 contestants banked £60.000
|Target of 17 Caught With 0:33 Remaining
|-
|95
|Mark Labbett
|All Contestants Caught One Brought Back To Battle For '''£4.000'''
|Target of 16 Caught With 0:16 Remaining
|-
|96
|Shaun Wallace
|2 contestants banked £5.000
|Target of 9 Caught With 0:42 Remaining
|-
|97
|Anne Hegerty
|3 contestants banked £12.000
|Target of 17/Chaser Scored 11<br/> Each Player Won '''£4.000'''
|-
|98
|Paul Sinha
|3 contestants banked £20.000
|Target of 16 Caught With 0:06 Remaining
|-
|99
|Anne Hegerty
|3 contestants banked £55.000
|Target of 18 Caught With 0:16 Remaining
|-
|100
|Mark Labbett
|4 contestants banked £17.000
|Target of 21/Chaser Scored 17<br/> Each Player Won '''£4.250'''
|-
|101
|Shaun Wallace
|1 contestant banked £3.000
|Target of 13 Caught With 0:47 Remaining
|-
|102
|Mark Labbett
|3 contestants banked £18.000
|Target of 19 Caught With 0:12 Remaining
|-
|103
|Shaun Wallace
|2 contestants banked £34.000
|Target of 12 Caught With 0:58 Remaining
|-
|104
|Mark Labbett
|3 contestants banked £16.000
|Target of 15 Caught With 0:25 Remaining
|-
|105
|Anne Hegerty
|1 contestant banked £3.000
|Target of 7 Caught With 1:31 Remaining
|-
|106
|Shaun Wallace
|4 contestants banked £19.000
|Target of 19/Chaser Scored 14<br/> Each Player Won '''£4.750'''
|-
|107
|Paul Sinha
|4 contestants banked £19.000
|Target of 19 Caught With 0:10 Remaining
|-
|108
|Mark Labbett
|1 contestant banked £3.000
|Target of 10 Caught With 0:54 Remaining
|-
|109
|Paul Sinha
|4 contestants banked £19.000
|Target of 24/Chaser Scored 16<br/> Each Player Won '''£4.750'''
|-
|110
|Anne Hegerty
|3 contestants banked £34.001
|Target of 19 Caught With 0:21 Remaining
|-
|111
|Paul Sinha
|3 contestants banked £11.000
|Target of 14 Caught With 0:05 Remaining
|-
|112
|Shaun Wallace
|2 contestants banked £80.000
|Target of 18/Chaser Scored 10<br/> Each Player Won '''£40.000'''
|-
|113
|Mark Labbett
|3 contestants banked £30.000
|Target of 14 Caught With 0:43 Remaining
|-
|114
|Shaun Wallace
|2 contestants banked £12.000
|Target of 17/Chaser Scored 16<br/> Each Player Won '''£6.000'''
|-
|115
|Anne Hegerty
|1 contestant banked £5.000
|Target of 10 Caught With 1:13 Remaining
|-
|116
|Paul Sinha
|2 contestants banked £21.000
|Target of 16 Caught With 0:21 Remaining
|-
|117
|Mark Labbett
|3 contestants banked £16.000
|Target of 17/Chaser Scored 11<br/> Each Player Won '''£5.333.33'''
|-
|118
|Paul Sinha
|2 contestants banked £6.000
|Target of 15 Caught With 0:32 Remaining
|-
|119
|Anne Hegerty
|2 contestants banked £10.000
|Target of 15/Chaser Scored 12<br/> Each Player Won '''£5.000'''
|-
|120
|Mark Labbett
|2 contestants banked £12.000
|Target of 13 Caught With 0:18 Remaining
|-
|121
|Shaun Wallace
|3 contestants banked £13.000
|Target of 12 Caught With 0:38 Remaining
|-
|122
|Paul Sinha
|2 contestants banked £4.000
|Target of 12 Caught With 0:30 Remaining
|-
|123
|Anne Hegerty
|1 contestant banked £40.000
|Target of 13 Caught With 0:31 Remaining
|-
|124
|Paul Sinha
|3 contestants banked £16.000
|Target of 15 Caught With 0:32 Remaining
|-
|125
|Mark Labbett
|1 contestant banked £5.000
|Target of 17 Caught With 0:26 Remaining
|-
|126
|Shaun Wallace
|3 contestants banked £10.000
|Target of 19/Chaser Scored 14<br/> Each Player Won '''£3.333.33'''
|-
|127
|Anne Hegerty
|1 contestant banked £5.000
|Target of 11 Caught With 1:09 Remaining
|-
|128
|Paul Sinha
|1 contestant banked £4.000
|Target of 17 Caught With 0:05 Remaining
|-
|129
|Mark Labbett
|3 contestants banked £17.000
|Target of 16 Caught With 0:13 Remaining
|-
|130
|Shaun Wallace
|1 contestant banked £45.000
|Target of 12 Caught With 0:17 Remaining
|-
|131
|Paul Sinha
|3 contestant banked £9.100
|Target of 18 Caught With 0:28 Remaining
|-
|132
|Anne Hegerty
|2 contestants banked £50.000
|Target of 17/Chaser Scored 15<br/> Each Player Won '''£25.000'''
|-
|133
|Shaun Wallace
|3 contestants banked £55.000
|Target of 15 Caught With 0:36 Remaining
|-
|134
|Anne Hegerty
|1 contestant banked £5.000
|Target of 13 Caught With 0:40 Remaining
|-
|135
|Shaun Wallace
|1 contestant banked £5.000
|Target of 20/Chaser Scored 11<br/> The Player Won '''£5.000'''
|-
|136
|Mark Labbett
|2 contestants banked £12.000
|Target of 19 Caught With 0:05 Remaining
|-
|137
|Paul Sinha
|2 contestants banked £27.000
|Target of 16 Caught With 0:02 Remaining
#!python3
import re
from sys import argv
def clean_table(table):
'''Clean the rows of the raw table for use in operations'''
rows = table.split('|-')
rows_lines = []
for row in rows:
row = row.replace('|', '')
row = row.replace('<br />', '')
row = row.replace('\'\'\'', '')
row = row.replace(',', '')
row = row.replace('.', '')
split_row = row.split('\n')
#remove all instances of ''
clean_row = filter((lambda item : item != ''), split_row)
rows_lines.append(list(clean_row))
return rows_lines
def format_row(row):
'''Reformats row to the desired format.
The format is:
Episode no. | Series | Chaser | Final Chase pot | No. contestants in
Final Chase | Chaser target | Chaser score | Chaser win? | Time
remaining | All caught? '''
episode_data = {
'episode' : None,
'series' : 7,
'chaser' : None,
'pot' : None,
'contestants' : None,
'target' : None,
'score' : None,
'cwin' : True,
'time' : 0,
'caught' : False
}
episode_data['episode'] = row[0]
episode_data['chaser'] = row[1]
# Regex for 3rd column of table
line_3 = row[2]
if line_3[0].upper() == 'A':
episode_data['pot'] = 4000
episode_data['contestants'] = 1
episode_data['caught'] = True
else:
l3_regex = re.compile(r'([1-4]) \w+ \w+ £([0-9]+)',
re.IGNORECASE)
l3_mo = l3_regex.search(line_3)
episode_data['pot'] = l3_mo.group(2)
episode_data['contestants'] = l3_mo.group(1)
# Regex for 4th column of table
line_4 = row[3]
if '£' in line_4:
l4_regex = re.compile(r'Target of ([0-9]+)/Chaser scored ([0-9]+)',
re.IGNORECASE)
l4_mo = l4_regex.search(line_4)
episode_data['target'] = l4_mo.group(1)
episode_data['score'] = l4_mo.group(2)
episode_data['cwin'] = False
else:
l4_regex = re.compile(r'Target of ([0-9]+) caught with ([0|1]):([0-9]){2} remaining',
re.IGNORECASE)
l4_mo = l4_regex.search(line_4)
episode_data['target'] = l4_mo.group(1)
episode_data['score'] = l4_mo.group(1)
episode_data['time'] = int(l4_mo.group(2)) * 60 + int(l4_mo.group(3))
return episode_data
def save_csv(eplist, filename):
'''Takes a list of episodes and saves it in .csv format'''
csv = open(filename, 'w')
header = "Episode no., Chaser, Final Chase Pot, No. Contestants in Final Chase, Chaser Target, Chaser Score, Time Remaining, Chaser Win?, All Caught?\n"
csv.write(header)
for episode in eplist:
line = (str(episode['episode']) + "," + \
str(episode['chaser']) + ","+ \
str(episode['pot']) + "," + \
str(episode['contestants']) + "," + \
str(episode['target']) + "," + \
str(episode['score']) + "," + \
str(episode['time']) + "," + \
str(episode['cwin']) + "," + \
str(episode['caught']) + '\n'
)
csv.write(line)
# === SCRIPT === #
script, filename = argv
table_file = open(filename, 'r')
input_table = table_file.read()
rows_lines = clean_table(input_table)
eps = []
for row in rows_lines:
eps.append(format_row(row))
save_csv(eps, "s7.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment