ayushkhare12

Email Sushmitha Script Task 2

Sep 26th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. from email_new_test import send_mail,username
  2. import pandas as pd
  3. import os
  4. import re
  5. emails_and_files = pd.read_csv('emails_and_files.csv',index_col='name')
  6. details = pd.read_csv('details.csv',index_col='Reportname')
  7.  
  8.  
  9. print(emails_and_files)
  10. for i in emails_and_files.index:
  11.     files = []
  12.     if i.startswith('mkt'):
  13.         for detail in details.index:
  14.             if details.loc[detail].mm == 't':
  15.                 path = os.path.join(detail,'pdf')
  16.                 for r, d, f in os.walk(path):
  17.                     if i in f:
  18.                         files.append(os.path.join(path,i))
  19.         send_mail(username,'{0} mm reports'.format(i),'PFA',emails_and_files.loc[i].email.split(';'),files=files)
  20.     elif re.match(r'^\d\d\d\d', i):
  21.         for detail in details.index:
  22.             if details.loc[detail].cm == 't':
  23.                 path = os.path.join(detail,'pdf')
  24.                 for r, d, f in os.walk(path):
  25.                     if i in f:
  26.                         files.append(os.path.join(path, i))
  27.         send_mail(username, '{0} cm reports'.format(i), 'PFA', emails_and_files.loc[i].email.split(';'), files=files)
  28.     elif re.search(r'region.',i):
  29.         for detail in details.index:
  30.             if details.loc[detail].rgm == 't':
  31.                 path = os.path.join(detail,'pdf')
  32.                 for r,d,f in os.walk(path):
  33.                     if i in f:
  34.                         files.append(os.path.join(path,i))
  35.         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