Guest User

Untitled

a guest
May 27th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. from openpyxl import load_workbook, Workbook
  2. from bcompiler.utils import project_data_from_master
  3.  
  4. current_Q_dict = project_data_from_master('C:\\Users\\Standalone\\Will\\masters folder\\master_4_2017.xlsx')
  5.  
  6. def filter_dictionary(dictionary, category):
  7. f_dict = {}
  8. for x in dictionary:
  9. if dictionary[x][category] != None:
  10. f_dict[x] = dictionary[x]
  11. return f_dict
  12.  
  13. def get_project_names(data):
  14. project_name_list = []
  15. for x in data:
  16. project_name_list.append(x)
  17. return project_name_list
  18.  
  19. current_Q_list = get_project_names(current_Q_dict)
  20.  
  21. output_wb = Workbook()
  22. ws = output_wb.active
  23.  
  24. for x in range(0, len(current_Q_list)):
  25. ws.cell(row=x+2, column=1, value=current_Q_list[x])
  26.  
  27. output_wb.save('C:\\Users\\Standalone\\Will\\masters folder\\Financial\\throw_away_list.xlsx')
  28.  
  29. wb = load_workbook('C:\\Users\\Standalone\\Will\\masters folder\\Financial\\throw_away_list.xlsx')
  30. ws = wb.active
  31.  
  32. for row_num in range(2, ws.max_row + 1):
  33. project_name = ws.cell(row=row_num, column=1).value
  34. print(project_name)
  35. if project_name in current_Q_dict:
  36. ws.cell(row=row_num, column=2).value = current_Q_dict[project_name]['Source of Finance']
  37. ws.cell(row=row_num, column=4).value = current_Q_dict[project_name]['Other Finance type Description']
  38.  
  39. ws.cell(row=1, column=1, value='Project')
  40. ws.cell(row=1, column=2, value='Source of finance')
  41. ws.cell(row=1, column=3, value='source of finance amended')
  42. ws.cell(row=1, column=4, value='notes')
  43.  
  44.  
  45. #ws.cell(row=1, column=4, value='Cost to closure')
  46.  
  47.  
  48.  
  49. wb.save('C:\\Users\\Standalone\\Will\\masters folder\\Financial\\source_finance_dash.xlsx')
Add Comment
Please, Sign In to add comment