import csv
from email_test import *
from cont_modules import *

# set collection code
collection_code = 'B_PHILPSYR'

# # get attachment, save it to file, then open file into variable
# attachment = open(checkmail(collection_code))
# # open saved attachment
# csv_reader = csv.reader(attachment)

# loop through inbox to find unreads with the proper file name
# will return attachment(s) somehow
loop_inbox()

# dict1 = ref_dict = {'A':'A_GEN', 'B':'B_PHILPSYR', 'C':'C_AUX-SCI-HIST', 'D':'D_WHIST', 'E':'E_MURICA-PT1', 'F':'F_MURICA-PT2', 'G':'G_GEO-REC', 'GN':'GN_ANTH', 'H1':'H_PS', 'HS':'H_SL', 'J':'J_POLI-SCI', 'K':'K_LAW', 'L':'L_EDU', 'M':'M_MUSIC', 'N':'N_ART', 'P':'P_LANG-LIT', 'Q':'Q_SCI', 'R':'R_MED', 'S':'S_AG', 'T':'T_TECH', 'U':'U_MIL-SCI', 'V':'V_NAVAL-SCI', 'Z':'Z_BIB-LIB-SCI'}

# for b in dict1:
#     # print(dict1[b])
#     date, collection, step = read_file_name('2020-08-18_' + dict1[b] + '_librarian_translated_final.csv')

#     print(date)
#     print(collection[0])
#     print(step)

# translate attachment to machine readable and resave
# write_csv_from_list(construct_ID('data/decisions/librarian_translated', collection_code), translate_csv_reader(csv_reader, 5))