Advertisement
UniQuet0p1

Untitled

Oct 2nd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import csv
  2.  
  3.  
  4. def read_production_data(filename: str) -> dict:
  5.     """
  6.    Open the file in the provided path, read in values and return them as a dictionary,
  7.    where the key is the machine name and value is a list of integers for the production data for each shift.
  8.  
  9.    {
  10.    'Machine Name': [Run Time (minutes), Ideal Run Rate (pcs/min), Total Count (pcs), Good Count (pcs)]
  11.    }
  12.  
  13.    :param filename: string file path for the CSV file to be read
  14.    :return: dictionary with the production data per machine
  15.    """
  16.     try:
  17.         with open(filename, "r") as input_file:
  18.             data = input_file.read()
  19.             if not data:
  20.                 raise ValueError('FileNotFoundError')
  21.     except IOError as e:
  22.         logging.exception(e)
  23.     return {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement