Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from email_new_test import send_mail,username
- import pandas as pd
- import os
- import re
- emails_and_files = pd.read_csv('emails_and_files.csv',index_col='name')
- details = pd.read_csv('details.csv',index_col='Reportname')
- print(emails_and_files)
- for i in emails_and_files.index:
- files = []
- if i.startswith('mkt'):
- for detail in details.index:
- if details.loc[detail].mm == 't':
- path = os.path.join(detail,'pdf')
- for r, d, f in os.walk(path):
- if i in f:
- files.append(os.path.join(path,i))
- send_mail(username,'{0} mm reports'.format(i),'PFA',emails_and_files.loc[i].email.split(';'),files=files)
- elif re.match(r'^\d\d\d\d', i):
- for detail in details.index:
- if details.loc[detail].cm == 't':
- path = os.path.join(detail,'pdf')
- for r, d, f in os.walk(path):
- if i in f:
- files.append(os.path.join(path, i))
- send_mail(username, '{0} cm reports'.format(i), 'PFA', emails_and_files.loc[i].email.split(';'), files=files)
- elif re.search(r'region.',i):
- for detail in details.index:
- if details.loc[detail].rgm == 't':
- path = os.path.join(detail,'pdf')
- for r,d,f in os.walk(path):
- if i in f:
- files.append(os.path.join(path,i))
- send_mail(username,'{0} rgm reports'.format(i), 'PFA', emails_and_files.loc[i].email.split(';'), files=files)
Add Comment
Please, Sign In to add comment