Created
October 2, 2020 08:53
-
-
Save PhilippThaler/4d5110b5664929b825d8146ddf0a6a2d to your computer and use it in GitHub Desktop.
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
#!/bin/python | |
import pyautogui | |
import time | |
import tabula | |
import re | |
path = '/home/philipp/Documents/zeitnachweis_september_philipp_thaler' | |
path_pdf = path + '.pdf' | |
path_csv = path + '.csv' | |
def get_date_file(): | |
tabula.convert_into(path_pdf, path_csv, output_format='csv', pages='all') | |
return tuple(open(path_csv, 'r')) | |
def get_time_list(path): | |
file = get_date_file() | |
regex = re.compile(r'[0-9]{2}.[0-9]{2}.*[0-9]{2}:[0-9]{2}') | |
working_hours = {} | |
for line in file: | |
if regex.search(line): | |
date_index = line.find('.') | |
date = line[(date_index - 2):(date_index + 3)] | |
working_hours[date] = [] | |
for line in file: | |
if regex.search(line): | |
date_index = line.find('.') | |
date = line[(date_index - 2):(date_index + 3)] | |
time_regex = re.compile(r'[0-9]{2}:[0-9]{2}') | |
working_hours[date].append(re.findall(time_regex, line)) | |
return working_hours; | |
columns = 11 | |
rows = 10 | |
time.sleep(5) | |
time_list =get_time_list(path) | |
print(time_list) | |
count = 0; | |
for date in time_list: | |
for times in time_list[date]: | |
pyautogui.typewrite(date+'.2020') | |
pyautogui.press('tab') | |
pyautogui.typewrite('A') | |
pyautogui.sleep(1) | |
pyautogui.press('enter') | |
for i in range(6): | |
pyautogui.press('tab') | |
pyautogui.typewrite(times[0]) | |
pyautogui.press('tab') | |
pyautogui.typewrite(times[1]) | |
for i in range(3): | |
pyautogui.press('tab') | |
count += 1 | |
if count == 4: | |
count = 0 | |
time.sleep(10) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment