-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from wookiemage/branch1
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
Showing
7 changed files
with
3,094 additions
and
3,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("")) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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""" |