Skip to content

Commit

Permalink
Merge pull request #6 from wookiemage/branch1
Browse files Browse the repository at this point in the history
updating a lot of code including creating a function that reads in a data file and a function that breaks down a target data file by male or female and presents percentages and a bar chart.
  • Loading branch information
ColinRNickels committed Apr 21, 2016
2 parents bc6e05a + c73eb8c commit e7c6dea
Show file tree
Hide file tree
Showing 7 changed files with 3,094 additions and 3,009 deletions.
15 changes: 7 additions & 8 deletions Main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!usr/bin/python3
userWantsToKeepGoing = True
while(userWantsToKeepGoing):
userSays = str(input("Do you want to keep going \n"))
print((userSays == "no"))
if(userSays == "no"):
userWantsToKeepGoing = False
else:
input("how about now?")
from menus import *
from fileChangers import *

print("Welcome to SalesData+ \n please choose an option:")
# topLevelMenu()
percentBreakdown("mock_data1.csv", 4)

28 changes: 28 additions & 0 deletions fileChangers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#This module holds my functions that manipulate files
def openFile(tarFile):
with open(tarFile) as temp:
fileDump = temp.readlines()
return fileDump
def percentBreakdown(tarFile, colNum):
q1 = 0
q2 = 0
with open(tarFile) as temp:
workingFile = temp.readlines()
table = []
for line in workingFile:
table.append(line.split(","))
for row in table:
# print(row[colNum])
# input()
if row[colNum] == "Male":
q1 = q1 + 1
elif row[colNum] == "Female":
q2 = q2 + 1
else:
continue
p1 = (q1/(q1+q2)*100)
p2 = 100 - p1
print("*" * int((p1/10)) + " - " + str(int(p1)) + " percent male")
print("*" * int((p2/10)) + " - " + str(int(p2)) + " percent female")


48 changes: 48 additions & 0 deletions menus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!usr/bin/python3
# This is where we host our functions that display menus
from variables import *
from fileChangers import *

def fileMenu():
print(optionsFiles)
going = True
while(going):
userSays = input("")
if(userSays == "5"):
topLevelMenu()
elif(userSays == "1"):
print("you said 1")
fileOpen = "mock_data1.csv"
return fileOpen
elif(userSays == "2"):
print("you said 2")
fileOpen = "mock_data2.csv"
return fileOpen
elif(userSays == "3"):
print("you said 3")
fileOpen = "mock_data3.csv"
return fileOpen
elif(userSays == "4"):
print("To import your own data, please go to the github repository and attach a file. \n Then come back here and rerun this program. \n If you've already done this, please give me the name of your file")
fileOpen = input("")
return fileOpen
else:
print("Please choose one of the options:" + optionsFiles)
continue



def topLevelMenu():
print(optionsTop)
going = True
while(going):
userSays = input("")
if(userSays == "3"):
going = False
elif(userSays == "1"):
thing = openFile(fileMenu())
print(thing)
elif(userSays == "2"):
print("To import your own data, please go to the github repository and attach a file. \n Then come back here and rerun this program. \n If you've already done this, please give me the name of your file")
openFile(input(""))

2,000 changes: 1,000 additions & 1,000 deletions mock_data1.csv

Large diffs are not rendered by default.

2,002 changes: 1,001 additions & 1,001 deletions mock_data2.csv

Large diffs are not rendered by default.

2,000 changes: 1,000 additions & 1,000 deletions mock_data3.csv

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!usr/bin/python3
# This is where we declare variables that effect the whole program
optionsTop = """1 - Open a file
2 - Import a file
3 - Exit"""
optionsFiles ="""1 - Open Mock Data 1
2 - Open Mock Data 2
3 - Open Mock Data 3
4 - Import your own data
5 - Exit to main menu"""

0 comments on commit e7c6dea

Please sign in to comment.