Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- filename = None
- metric = None
- action = None
- def read(filename):
- with open(filename) as file:
- filecontents = file.read()
- print(filecontents)
- def column(filename):
- with open(filename, 'r') as f:
- results []
- for line in f:
- words = line.split(',')
- results.append((words[0], words[1:]))
- #results.append((words[0], words[1:]))
- # print(results)
- #def min_calculation():
- #def mean_calculation()
- #def median_calculation():
- #def harmonic_mean_calculation():
- def calculation(metric,action):
- if action == "list":
- if metric == "min":
- action == None
- elif metric == "mean":
- action == None
- elif metric == "median":
- action == None
- elif metric == "harmonic mean":
- action == None
- elif action == "correlation":
- if metric == "min":
- action == None
- elif metric == "mean":
- action == None
- elif metric == "median":
- action == None
- elif metric == "harmonic mean":
- action == None
- # DO CAPITAL LETTERS AND SPACE CHECK
- def file_noexist(filename):
- if not os.path.isfile(filename):
- filename = input("This file does not exist, please enter the name of the file you wish to read ").lower().strip()
- file_noexist(filename)
- def metric_noexist(metric):
- if metric not in {"min", "mean", "median", "harmonic mean"}:
- metric = input("Incorrect choice, please choose a metric from min, mean, median, harmonic mean ").lower().strip()
- metric_noexist(metric)
- def action_noexist(action):
- if action not in {"list","correlation"}:
- action = input(
- "Incorrect choice, please chose an action to be performed on the data using the specified metric. "
- "Options are list, correlation ").lower().strip()
- action_noexist(action)
- def userinput():
- filename = input("Enter the name of the file you wish to read ").lower().strip()
- file_noexist(filename)
- metric = input("Please choose a metric from min, mean, median, harmonic mean ").lower().strip()
- metric_noexist(metric)
- action = input("Chose action to be performed on the data using the specified metric. Options are list, correlation ").lower().strip()
- action_noexist(action)
- return filename, metric, action
- def main():
- filename, metic, action = userinput()
- read(filename)
- column(filename)
- calculation(metric,action)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement