Start Date
Start Date
start_date_report:
#!/usr/bin/env python3
import csv
import datetime
import requests
FILE_URL="https://raw.githubusercontent.com/google/it-cert-automation-
practice/master/Course4/Lab4/employees-with-date.csv"
def get_start_date():
"""Interactively get the start date to query for."""
print()
print('Getting the first start date to query for.')
print()
print('The date must be greater than Jan 1st, 2018')
year = input('Enter a value for the year: ')
month = input('Enter a value for the month: ')
day = input('Enter a value for the day: ')
print()
def get_file_lines(url):
"""Returns the lines contained in the file at the given URL"""
my_data = get_file_lines(FILE_URL)
def get_same_or_newer(start_date):
"""Returns the employees that started on the given date, or the closest one."""
data = get_file_lines(FILE_URL)
reader = csv.reader(data[1:])
lista = list(reader)
lista.sort(key=lambda x: x[3])
# We want all employees that started at the same date or the closest newer
# date. To calculate that, we go through all the data and find the
# employees that started on the smallest date that's equal or bigger than
# the given start date.
min_date = ()
min_date_employees = []
for row in reader:
row_date = datetime.datetime.strptime(row[3], '%Y-%m-%d')
def list_newer(start_date):
while start_date < ():
start_date, employees = get_same_or_newer(start_date)
print("Started on {}: {}".format(start_date.strftime("%b %d, %Y"),
employees))
if __name__ == "__main__":
main()
Type a message here...