initial commit

This commit is contained in:
lottopy committed 2022-06-12 11:55:02 -04:00
commit 9df6a949a8
24 files changed
+607

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
WVLotto.py
This script generates the five most likely lottery numbers and one powerball, based off frequency pulled.
This script uses an excel sheet to store the history of all WV Lottery numbers since 1992. It does NOT however guarantee you will win.
Good luck!
# lottopy_web_edition
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,Chance
14-18-2-22-5-9,49/25300
1 Winning_Numbers Chance
2 14-18-2-22-5-9 49/25300
Executable
+82
View File
@@ -0,0 +1,82 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
url = 'https://wvlottery.com/draw-games/cash-25/?game-analyze=cash-25&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./cash25.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("cash25.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
#PB = list(df['PB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='cash25.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='cash25.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 25):
most_common= Counter(sep).most_common(6)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
#for n in range(0, 26):
# most_common_pb = Counter(PB).most_common(1)
# likely_pb = [v[0] for v in most_common_pb]
# frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency)
Chance = frac(total_freq, 177100) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
h = 'Winning_Numbers', 'Chance'
f = open('c25_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
BIN
View File
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
# Powerball
1 23 * * 1,3,6
# Mega Mil
0 23 * * 2,5
# Lotto America
31 22 * * 3,6
# D3, D4, C25 (Every day but sunday 7:00)
0 19 * * 1,2,3,4,5,6
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,Chance
0-3-8,33/10000
1 Winning_Numbers Chance
2 0-3-8 33/10000
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,Chance
3-5-6-8,537/10000
1 Winning_Numbers Chance
2 3-5-6-8 537/10000
Executable
+83
View File
@@ -0,0 +1,83 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./daily3.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("daily3.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
#PB = list(df['PB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
#index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='daily3.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='daily3.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 10):
most_common= Counter(sep).most_common(3)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
#for n in range(0, 26):
# most_common_pb = Counter(PB).most_common(1)
# likely_pb = [v[0] for v in most_common_pb]
# frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency)
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
h = 'Winning_Numbers', 'Chance'
f = open('d3_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
BIN
View File
Binary file not shown.
Executable
+82
View File
@@ -0,0 +1,82 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
url = 'https://wvlottery.com/draw-games/daily-4/?game-analyze=daily-4&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./daily4.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("daily4.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
#PB = list(df['PB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
#index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='daily4.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='daily4.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 9):
most_common= Counter(sep).most_common(4)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
#for n in range(0, 26):
# most_common_pb = Counter(PB).most_common(1)
# likely_pb = [v[0] for v in most_common_pb]
# frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency)
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
h = 'Winning_Numbers', 'Chance'
f = open('d4_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,SB,Chance
1-10-32-49-8,[9],1/265200
1 Winning_Numbers SB Chance
2 1-10-32-49-8 [9] 1/265200
BIN
View File
Binary file not shown.
+84
View File
@@ -0,0 +1,84 @@
# WVLottopy: Matteo DiBiagio
#from django_lottopy.lottopy_site.lottopy.lottopy_web_edition.megamil import Winning_Numbers
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
url = 'https://wvlottery.com/draw-games/lotto-america/?game-analyze=lotto-america&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers', 'SB', 'All Star']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./lotto_america.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("lotto_america.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
PBs = list(df['SB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='lotto_america.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='lotto_america.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 52):
most_common= Counter(sep).most_common(5)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
for n in range(0, 10):
most_common_pb = Counter(PBs).most_common(1)
SB = [v[0] for v in most_common_pb]
frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency + frequency_pb)
Chance = frac(total_freq, 25989600) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "SB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'SB', 'Chance')))
h = 'Winning_Numbers', 'SB', 'Chance'
f = open('la_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
Binary file not shown.
Binary file not shown.
Executable
+86
View File
@@ -0,0 +1,86 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
def fraction_ratio(i):
return i/sum(i)
url = 'https://wvlottery.com/draw-games/powerball/?game-analyze=powerball&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers', 'PB', 'PPX', 'Winners WV Only', 'Payout WV Only']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./lotto.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("lotto.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
PBs = list(df['PB'].astype('int'))
appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='lotto.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='lotto.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 69):
most_common= Counter(sep).most_common(5)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
for n in range(0, 26):
most_common_pb = Counter(PBs).most_common(1)
PB = [v[0] for v in most_common_pb]
frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency + frequency_pb)
Chance = frac(total_freq, 292201338) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "PB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'PB', 'Chance')))
h = 'Winning_Numbers', 'PB', 'Chance'
f = open('pb_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
Executable
+82
View File
@@ -0,0 +1,82 @@
# WVLottopy megamil: Matteo DiBiagio
from fractions import Fraction as frac
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
import csv
url = 'https://wvlottery.com/draw-games/mega-millions/?game-analyze=mega-millions&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers', 'MB', 'MP']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('./lotto_megamil.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("lotto_megamil.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
PBs = list(df['MB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='lotto_megamil.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='lotto_megamil.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 70):
most_common= Counter(sep).most_common(5)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
for n in range(0, 25):
most_common_pb = Counter(PBs).most_common(1)
MB = [v[0] for v in most_common_pb]
frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency + frequency_pb)
Chance = frac(total_freq, 302575350) # Chance = number call freq / all possible numbers i.e. 11238513
Winning_Numbers = str("-".join(sorted_nums))
#print("Likely numbers are . . . ", sorted_nums, "MB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'MB', 'Chance')))
h = 'Winning_Numbers', 'MB', 'Chance'
f = open('mm_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,MB,Chance
17-3-40-52-7,[24],38/151287675
1 Winning_Numbers MB Chance
2 17-3-40-52-7 [24] 38/151287675
+2
View File
@@ -0,0 +1,2 @@
Winning_Numbers,PB,Chance
21-39-59-61-63,[17],50/146100669
1 Winning_Numbers PB Chance
2 21-39-59-61-63 [17] 50/146100669
+3
View File
@@ -0,0 +1,3 @@
pandas==1.3.5
requests==2.26.0
sheet2dict==0.1.1
+73
View File
@@ -0,0 +1,73 @@
# WVLottopy: Matteo DiBiagio
from sheet2dict import Worksheet
import pandas as pd
import requests
from collections import Counter
url = 'https://wvlottery.com/draw-games/powerball/?game-analyze=powerball&what-to-search=historysearch&date-range=-1'
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
#print(len(dfs))
df = dfs[0]
df2 = df[['Date', 'Numbers', 'PB', 'PPX', 'Winners WV Only', 'Payout WV Only']]
# Print Table
#print(df2)
# To excel file
df2.to_excel('../lottopy/lotto.xlsx')
#Insert complete path to the excel file and index of the worksheet
df = pd.read_excel("lotto.xlsx", sheet_name=0)
# insert the name of the column as a string in brackets
date = list(df['Date'])
nums = list(df['Numbers'].astype('str'))
PB = list(df['PB'].astype('int'))
appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
index = [i for i in range(0,len(nums)*6)]
# Create an object
ws = Worksheet()
# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='lotto.xlsx')
# Convert sheet of the 'lotto.xslx' spreadsheet file.
ws.xlsx_to_dict(path='lotto.xlsx', select_sheet='Sheet1')
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
#print(ws.header)
#print(ws.sheet_items)
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
for n in range(0, 69):
most_common= Counter(sep).most_common(5)
likely_nums = [v[0] for v in most_common]
frequency = [v[-1] for v in most_common]
for n in range(0, 26):
most_common_pb = Counter(PB).most_common(1)
likely_pb = [v[0] for v in most_common_pb]
frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums)
total_freq = sum(frequency + frequency_pb)
chance = [(total_freq / 292201338) * 100] # Chance = number call freq / all possible numbers i.e. 11238513
print("Likely numbers are . . . ", sorted_nums, "PB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
Executable
+1
View File
@@ -0,0 +1 @@
echo "Powerball" && python lottopy_pb.py && echo "MegaMillions" && python megamil.py && echo "Lotto America" && python lotto_america.py && echo "Daily3" && python daily3.py && echo "Daily4" && python daily4.py && echo "Cash25" && python cash25.py